[PATCH v2] multipath: check for NULL from udev_device_get_*

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The udev_device_get_* functions can return NULL, an occassionally do
so in the multipathd code.  multipath needs to check if the result
is NULL before dereferencing it.

Signed-off-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx>
---
 libmultipath/discovery.c |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

Index: multipath-tools-120821/libmultipath/discovery.c
===================================================================
--- multipath-tools-120821.orig/libmultipath/discovery.c
+++ multipath-tools-120821/libmultipath/discovery.c
@@ -113,6 +113,7 @@ path_discovery (vector pathvec, struct c
 
 	udev_list_entry_foreach(entry,
 				udev_enumerate_get_list_entry(udev_iter)) {
+		const char *devtype;
 		devpath = udev_list_entry_get_name(entry);
 		condlog(4, "Discover device %s", devpath);
 		udevice = udev_device_new_from_syspath(conf->udev, devpath);
@@ -121,7 +122,8 @@ path_discovery (vector pathvec, struct c
 			r++;
 			continue;
 		}
-		if(!strncmp(udev_device_get_devtype(udevice), "disk", 4))
+		devtype = udev_device_get_devtype(udevice);
+		if(devtype && !strncmp(devtype, "disk", 4))
 			r += path_discover(pathvec, conf, udevice, flag);
 		udev_device_unref(udevice);
 	}
@@ -459,7 +461,8 @@ scsi_sysfs_pathinfo (struct path * pp)
 
 	parent = pp->udev;
 	while (parent) {
-		if (!strncmp(udev_device_get_subsystem(parent), "scsi", 4)) {
+		const char *subsys = udev_device_get_subsystem(parent);
+		if (subsys && !strncmp(subsys, "scsi", 4)) {
 			attr_path = udev_device_get_sysname(parent);
 			if (!attr_path)
 				break;
@@ -525,7 +528,8 @@ ccw_sysfs_pathinfo (struct path * pp)
 
 	parent = pp->udev;
 	while (parent) {
-		if (!strncmp(udev_device_get_subsystem(parent), "ccw", 3))
+		const char *subsys = udev_device_get_subsystem(parent);
+		if (subsys && !strncmp(subsys, "ccw", 3))
 			break;
 		parent = udev_device_get_parent(parent);
 	}
@@ -581,7 +585,8 @@ cciss_sysfs_pathinfo (struct path * pp)
 
 	parent = pp->udev;
 	while (parent) {
-		if (!strncmp(udev_device_get_subsystem(parent), "cciss", 5)) {
+		const char *subsys = udev_device_get_subsystem(parent);
+		if (subsys && !strncmp(subsys, "cciss", 5)) {
 			attr_path = udev_device_get_sysname(parent);
 			if (!attr_path)
 				break;
@@ -662,7 +667,8 @@ path_offline (struct path * pp)
 
 	parent = pp->udev;
 	while (parent) {
-		if (!strncmp(udev_device_get_subsystem(parent), "scsi", 4))
+		const char *subsys = udev_device_get_subsystem(parent);
+		if (subsys && !strncmp(subsys, "scsi", 4))
 			break;
 		parent = udev_device_get_parent(parent);
 	}

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


[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux