All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Wilck <mwilck@suse.com>
To: lixiaokeng <lixiaokeng@huawei.com>,
	Christophe Varoqui <christophe.varoqui@opensvc.com>,
	Benjamin Marzinski <bmarzins@redhat.com>,
	dm-devel mailing list <dm-devel@redhat.com>
Cc: linfeilong <linfeilong@huawei.com>,
	"liuzhiqiang (I)" <liuzhiqiang26@huawei.com>
Subject: Re: [PATCH 6/6] libmultipath: check udev* return value in _find_path_by_syspath
Date: Fri, 18 Sep 2020 08:58:08 +0200	[thread overview]
Message-ID: <8d91632f52d943cb7e95b4b8cc595fc4720ee83f.camel@suse.com> (raw)
In-Reply-To: <40f72a77-5dcc-89e4-e164-d19e0da10699@huawei.com>

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@huawei.com>
> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
> Signed-off-by: Linfeilong <linfeilong@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.

  reply	other threads:[~2020-09-18  6:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-15  4:38 [PATCH 0/6] libmultipath: check udev* func return value lixiaokeng
2020-09-15  4:39 ` [PATCH 1/6] libmultipath: check uedv* return value in sysfs_get_host_pci_name lixiaokeng
2020-09-18  7:34   ` Martin Wilck
2020-09-15  4:39 ` [PATCH 2/6] libmultipath: check udev* return value in ccw_sysfs_pathinfo lixiaokeng
2020-09-18  7:01   ` Martin Wilck
2020-09-15  4:40 ` [PATCH 3/6] libmultipath: check udev* return value in sysfs_get_tgt_nodename lixiaokeng
2020-09-15  4:41 ` [PATCH 4/6] libmultipath: check udev* return value in trigger_partitions_udev_change lixiaokeng
2020-09-15  4:41 ` [PATCH 5/6] libmultipath: check udev* renturn value in get_ctrl_blkdev lixiaokeng
2020-09-18  6:59   ` Martin Wilck
2020-09-15  4:42 ` [PATCH 6/6] libmultipath: check udev* return value in _find_path_by_syspath lixiaokeng
2020-09-18  6:58   ` Martin Wilck [this message]
2020-09-18  2:26 ` [PATCH 0/6] libmultipath: check udev* func return value Benjamin Marzinski
2020-09-18  7:37   ` Martin Wilck
2020-09-18  8:39     ` lixiaokeng
2020-09-18 11:15       ` Martin Wilck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8d91632f52d943cb7e95b4b8cc595fc4720ee83f.camel@suse.com \
    --to=mwilck@suse.com \
    --cc=bmarzins@redhat.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dm-devel@redhat.com \
    --cc=linfeilong@huawei.com \
    --cc=liuzhiqiang26@huawei.com \
    --cc=lixiaokeng@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.