From: Martin Wilck <mwi...@suse.com>

All libudev functions may return NULL. Watch out for it.

Fixes: d041258 ("libmultipath: snprint_devices(): use udev_enumerate"
Signed-off-by: Martin Wilck <mwi...@suse.com>
---
 libmultipath/print.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libmultipath/print.c b/libmultipath/print.c
index 19de2c7..8151e11 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.29.2


--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

Reply via email to