All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] multipath: check for NULL from udev_device_get_*
@ 2013-01-10 21:00 Benjamin Marzinski
  0 siblings, 0 replies; only message in thread
From: Benjamin Marzinski @ 2013-01-10 21:00 UTC (permalink / raw)
  To: device-mapper development; +Cc: Christophe Varoqui

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@redhat.com>
---
 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);
 	}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-01-10 21:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-10 21:00 [PATCH v2] multipath: check for NULL from udev_device_get_* Benjamin Marzinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.