39 lines
1.1 KiB
Diff
39 lines
1.1 KiB
Diff
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||
|
From: Martin Wilck <mwilck@suse.com>
|
||
|
Date: Mon, 25 Jan 2021 16:12:10 +0100
|
||
|
Subject: [PATCH] libmultipath: snprint_devices(): avoid NULL dereference
|
||
|
|
||
|
All libudev functions may return NULL. Watch out for it.
|
||
|
|
||
|
Fixes: d041258 ("libmultipath: snprint_devices(): use udev_enumerate"
|
||
|
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||
|
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||
|
---
|
||
|
libmultipath/print.c | 8 ++++++++
|
||
|
1 file changed, 8 insertions(+)
|
||
|
|
||
|
diff --git a/libmultipath/print.c b/libmultipath/print.c
|
||
|
index 19de2c7c..8151e11e 100644
|
||
|
--- a/libmultipath/print.c
|
||
|
+++ b/libmultipath/print.c
|
||
|
@@ -2055,8 +2055,16 @@ int snprint_devices(struct config *conf, char *buff, size_t len,
|
||
|
struct udev_device *u_dev;
|
||
|
|
||
|
path = udev_list_entry_get_name(item);
|
||
|
+ if (!path)
|
||
|
+ continue;
|
||
|
u_dev = udev_device_new_from_syspath(udev, path);
|
||
|
+ if (!u_dev)
|
||
|
+ continue;
|
||
|
devname = udev_device_get_sysname(u_dev);
|
||
|
+ if (!devname) {
|
||
|
+ udev_device_unref(u_dev);
|
||
|
+ continue;
|
||
|
+ }
|
||
|
|
||
|
fwd += snprintf(buff + fwd, len - fwd, " %s", devname);
|
||
|
if (fwd >= len)
|
||
|
--
|
||
|
2.17.2
|
||
|
|