summaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
authorWenchao Hao <haowenchao@huawei.com>2020-11-30 21:41:56 +0800
committerWenchao Hao <haowenchao@huawei.com>2020-12-12 11:44:24 +0800
commitbe3b317705cbfdd694deae92db7f6e0458e702c0 (patch)
treee60c684f5fa0fee4a4948c7d018b60c99e9e9946 /usr
parent873fb12261b8dfa2d4512ce28ad9bc8f48efd66d (diff)
downloadopen-iscsi-be3b317705cbfdd694deae92db7f6e0458e702c0.tar.gz
sysfs: Verify parameter of sysfs_device_get()
In sysfs_device_get() we should firstly check whether devpath pointer is NULL before accessing it Signed-off-by: Wenchao Hao <haowenchao@huawei.com> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Signed-off-by: Wu Bo <wubo40@huawei.com>
Diffstat (limited to 'usr')
-rw-r--r--usr/sysfs.c6
1 files 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 &&