DPDK patches and discussions
 help / color / mirror / Atom feed
From: Marcin Kerlin <marcinx.kerlin@intel.com>
To: changchun.ouyang@intel.com
Cc: huawei.xie@intel.com, yuanhan.liu@linux.intel.com, dev@dpdk.org,
	Marcin Kerlin <marcinx.kerlin@intel.com>
Subject: [dpdk-dev] [PATCH 1/1] vhost: fix null pointer dereference
Date: Wed, 15 Jun 2016 11:47:22 +0200	[thread overview]
Message-ID: <1465984042-21634-1-git-send-email-marcinx.kerlin@intel.com> (raw)

Return value of function get_device() is not checking before
dereference. Fix this problem by adding checking condition.

Coverity issue: 119262
Fixes: 77d20126b4c2 ("vhost-user: handle message to enable vring")

Signed-off-by: Marcin Kerlin <marcinx.kerlin@intel.com>
---
 lib/librte_vhost/vhost_user/virtio-net-user.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c b/lib/librte_vhost/vhost_user/virtio-net-user.c
index f5248bc..94959f2 100644
--- a/lib/librte_vhost/vhost_user/virtio-net-user.c
+++ b/lib/librte_vhost/vhost_user/virtio-net-user.c
@@ -332,9 +332,13 @@ int
 user_set_vring_enable(struct vhost_device_ctx ctx,
 		      struct vhost_vring_state *state)
 {
-	struct virtio_net *dev = get_device(ctx);
+	struct virtio_net *dev;
 	int enable = (int)state->num;
 
+	dev = get_device(ctx);
+	if (dev == NULL)
+		return -1;
+
 	RTE_LOG(INFO, VHOST_CONFIG,
 		"set queue enable: %d to qp idx: %d\n",
 		enable, state->index);
-- 
1.9.1

             reply	other threads:[~2016-06-15  8:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-15  9:47 Marcin Kerlin [this message]
2016-06-15  9:01 ` Yuanhan Liu

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=1465984042-21634-1-git-send-email-marcinx.kerlin@intel.com \
    --to=marcinx.kerlin@intel.com \
    --cc=changchun.ouyang@intel.com \
    --cc=dev@dpdk.org \
    --cc=huawei.xie@intel.com \
    --cc=yuanhan.liu@linux.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).