[dm-devel] [PATCH 6/6] libmultipath: check udev* return value in _find_path_by_syspath
Martin Wilck
mwilck at suse.com
Fri Sep 18 06:58:08 UTC 2020
On Tue, 2020-09-15 at 12:42 +0800, lixiaokeng wrote:
> We check udev_device_get_syspath return value 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, 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);
This looks wrong to me.
More information about the dm-devel
mailing list