From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 73988ADED for ; Wed, 15 Jun 2016 10:38:41 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP; 15 Jun 2016 01:38:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,475,1459839600"; d="scan'208";a="997982293" Received: from gklab-246-021.igk.intel.com (HELO HANLANCREEK9755-232) ([10.217.246.21]) by orsmga002.jf.intel.com with SMTP; 15 Jun 2016 01:38:37 -0700 Received: by HANLANCREEK9755-232 (sSMTP sendmail emulation); Wed, 15 Jun 2016 11:47:27 +0200 From: Marcin Kerlin To: changchun.ouyang@intel.com Cc: huawei.xie@intel.com, yuanhan.liu@linux.intel.com, dev@dpdk.org, Marcin Kerlin Date: Wed, 15 Jun 2016 11:47:22 +0200 Message-Id: <1465984042-21634-1-git-send-email-marcinx.kerlin@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH 1/1] vhost: fix null pointer dereference X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 08:38:41 -0000 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 --- 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