In sysfs_device_get() we should firstly check whether devpath pointer is NULL before accessing it
Signed-off-by: Wenchao Hao <haowenc...@huawei.com> Signed-off-by: Zhiqiang Liu <liuzhiqian...@huawei.com> Signed-off-by: Wu Bo <wub...@huawei.com> --- usr/sysfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/usr/sysfs.c b/usr/sysfs.c index 8d37c69..7f26572 100644 --- a/usr/sysfs.c +++ b/usr/sysfs.c @@ -168,9 +168,11 @@ struct sysfs_device *sysfs_device_get(const char *devpath) int len; char *pos; + if (!devpath) + return NULL; + /* we handle only these devpathes */ - if (devpath != NULL && - strncmp(devpath, "/devices/", 9) != 0 && + if (strncmp(devpath, "/devices/", 9) != 0 && strncmp(devpath, "/subsystem/", 11) != 0 && strncmp(devpath, "/module/", 8) != 0 && strncmp(devpath, "/bus/", 5) != 0 && -- 2.27.0 -- You received this message because you are subscribed to the Google Groups "open-iscsi" group. To unsubscribe from this group and stop receiving emails from it, send an email to open-iscsi+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/open-iscsi/20201207015410.48488-10-haowenchao%40huawei.com.