[dm-devel] [PATCH 5/6] libmultipath: check udev* renturn value in get_ctrl_blkdev
lixiaokeng
lixiaokeng at huawei.com
Tue Sep 15 04:41:41 UTC 2020
We check return value of udev_device_get_devtype before
dereference it.
Signed-off-by:Lixiaokeng<lixiaokeng at huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26 at huawei.com>
Signed-off-by: Linfeilong <linfeilong at huawei.com>
---
libmultipath/foreign/nvme.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libmultipath/foreign/nvme.c b/libmultipath/foreign/nvme.c
index 0bc5106e..a0668713 100644
--- a/libmultipath/foreign/nvme.c
+++ b/libmultipath/foreign/nvme.c
@@ -538,6 +538,7 @@ struct udev_device *get_ctrl_blkdev(const struct context *ctx,
struct udev_list_entry *item;
struct udev_device *blkdev = NULL;
struct udev_enumerate *enm = udev_enumerate_new(ctx->udev);
+ const char *devtype;
if (enm == NULL)
return NULL;
@@ -562,7 +563,9 @@ struct udev_device *get_ctrl_blkdev(const struct context *ctx,
udev_list_entry_get_name(item));
if (tmp == NULL)
continue;
- if (!strcmp(udev_device_get_devtype(tmp), "disk")) {
+
+ devtype = udev_device_get_devtype(tmp);
+ if (!devtype && !strcmp(devtype, "disk")) {
blkdev = tmp;
break;
} else
--
More information about the dm-devel
mailing list