From: Benjamin Marzinski <bmarzins@redhat.com>
To: device-mapper development <dm-devel@redhat.com>
Cc: Christophe Varoqui <christophe.varoqui@gmail.com>
Subject: [PATCH v2] multipath: check for NULL from udev_device_get_*
Date: Thu, 10 Jan 2013 15:00:56 -0600 [thread overview]
Message-ID: <20130110210056.GC19059@ether.msp.redhat.com> (raw)
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);
}
reply other threads:[~2013-01-10 21:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130110210056.GC19059@ether.msp.redhat.com \
--to=bmarzins@redhat.com \
--cc=christophe.varoqui@gmail.com \
--cc=dm-devel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.