We check udev_device_get_syspath return value before dereference it. Signed-off-by: Lixiaokeng<lixiaok...@huawei.com> Signed-off-by: Zhiqiang Liu <liuzhiqian...@huawei.com> Signed-off-by: Linfeilong <linfeil...@huawei.com> --- libmultipath/foreign/nvme.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libmultipath/foreign/nvme.c b/libmultipath/foreign/nvme.c index a0668713..28e0d192 100644 --- a/libmultipath/foreign/nvme.c +++ b/libmultipath/foreign/nvme.c @@ -482,6 +482,7 @@ _find_path_by_syspath(struct nvme_map *map, const char *syspath) struct nvme_pathgroup *pg; char real[PATH_MAX]; const char *ppath; + const char *psyspath; int i; ppath = realpath(syspath, real); @@ -493,8 +494,8 @@ _find_path_by_syspath(struct nvme_map *map, const char *syspath) vector_foreach_slot(&map->pgvec, pg, i) { struct nvme_path *path = nvme_pg_to_path(pg); - if (!strcmp(ppath, - udev_device_get_syspath(path->udev))) + psyspath = udev_device_get_syspath(path->udev); + if (!psyspath && !strcmp(ppath, psyspath)) return path; } condlog(4, "%s: %s: %s not found", __func__, THIS, ppath); -- -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel