From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: Huawei Xie <huawei.xie@intel.com>
Cc: dev@dpdk.org, yuanhan.liu@intel.com, michalx.k.jastrzebski@intel.com
Subject: Re: [dpdk-dev] [PATCH] vhost: fix dereference null return value
Date: Mon, 20 Jun 2016 14:18:57 +0800 [thread overview]
Message-ID: <20160620061857.GD23111@yliu-dev.sh.intel.com> (raw)
In-Reply-To: <1465950765-53868-1-git-send-email-huawei.xie@intel.com>
On Wed, Jun 15, 2016 at 08:32:45AM +0800, Huawei Xie wrote:
> fixes the following coverity issues:
> CID 107118 (#1 of 1): Dereference null return value (NULL_RETURNS)
> CID 119262 (#1 of 1): Dereference null return value (NULL_RETURNS)
>
> Fixes: 8f972312b8f4 ("vhost: support vhost-user")
> Fixes: 77d20126b4c2 ("vhost-user: handle message to enable vring")
>
> Signed-off-by: Huawei Xie <huawei.xie@intel.com>
> ---
> lib/librte_vhost/vhost_user/virtio-net-user.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c b/lib/librte_vhost/vhost_user/virtio-net-user.c
> index 5803182..5844a42 100644
> --- a/lib/librte_vhost/vhost_user/virtio-net-user.c
> +++ b/lib/librte_vhost/vhost_user/virtio-net-user.c
> @@ -283,6 +283,9 @@ user_set_vring_kick(struct vhost_device_ctx ctx, struct VhostUserMsg *pmsg)
> struct vhost_vring_file file;
> struct virtio_net *dev = get_device(ctx);
>
> + if (!dev)
> + return;
> +
I just found that it's been fixed by commit a03aabf2e8d6 ("vhost: export
vid as the only interface to applications"), "accidentally".
> file.index = pmsg->payload.u64 & VHOST_USER_VRING_IDX_MASK;
> if (pmsg->payload.u64 & VHOST_USER_VRING_NOFD_MASK)
> file.fd = VIRTIO_INVALID_EVENTFD;
> @@ -306,8 +309,9 @@ user_get_vring_base(struct vhost_device_ctx ctx,
> {
> struct virtio_net *dev = get_device(ctx);
>
> - if (dev == NULL)
> + if (!dev)
> return -1;
What's that for? Interestingly, if you look at the DPDK coding style,
you will find that it's encouraged to use "dev == NULL" check instead
of the "!dev" check. I sometimes uses both though.
So, I don't think it's a big deal, and I will leave it as it is.
> +
> /* We have to stop the queue (virtio) if it is running. */
> if (dev->flags & VIRTIO_DEV_RUNNING)
> notify_ops->destroy_device(dev);
> @@ -341,6 +345,9 @@ user_set_vring_enable(struct vhost_device_ctx ctx,
> struct virtio_net *dev = get_device(ctx);
> int enable = (int)state->num;
>
> + if (!dev)
> + return -1;
> +
It's been fixed by commit 590a936287c6 ("vhost: fix null pointer
dereference").
So, sorry, I will NACK this patch.
--yliu
prev parent reply other threads:[~2016-06-20 6:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-15 0:32 Huawei Xie
2016-06-20 6:18 ` Yuanhan Liu [this message]
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=20160620061857.GD23111@yliu-dev.sh.intel.com \
--to=yuanhan.liu@linux.intel.com \
--cc=dev@dpdk.org \
--cc=huawei.xie@intel.com \
--cc=michalx.k.jastrzebski@intel.com \
--cc=yuanhan.liu@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).