From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 939DDA6A for ; Tue, 5 Apr 2016 07:59:17 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 04 Apr 2016 22:59:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,442,1455004800"; d="scan'208";a="948172247" Received: from yliu-dev.sh.intel.com ([10.239.67.191]) by orsmga002.jf.intel.com with ESMTP; 04 Apr 2016 22:59:15 -0700 From: Yuanhan Liu To: dev@dpdk.org Cc: huawei.xie@intel.com, Thomas Monjalon , Yuanhan Liu Date: Tue, 5 Apr 2016 14:00:43 +0800 Message-Id: <1459836043-18863-1-git-send-email-yuanhan.liu@linux.intel.com> X-Mailer: git-send-email 1.9.0 Subject: [dpdk-dev] [PATCH] vhost: fix coverity defect 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: Tue, 05 Apr 2016 05:59:18 -0000 Fix following coverity defect: 291 void 292 vhost_destroy_device(struct vhost_device_ctx ctx) 293 { 294 struct virtio_net *dev = get_device(ctx); 295 >>> CID 124565: Null pointer dereferences (NULL_RETURNS) >>> Dereferencing a null pointer "dev". Fixes: 45ca9c6f7bc6 ("vhost: get rid of linked list for devices") Reported-by: John McNamara Signed-off-by: Yuanhan Liu --- lib/librte_vhost/virtio-net.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c index 90da9ba..d870ad9 100644 --- a/lib/librte_vhost/virtio-net.c +++ b/lib/librte_vhost/virtio-net.c @@ -293,6 +293,9 @@ vhost_destroy_device(struct vhost_device_ctx ctx) { struct virtio_net *dev = get_device(ctx); + if (dev == NULL) + return; + if (dev->flags & VIRTIO_DEV_RUNNING) notify_ops->destroy_device(dev); -- 1.9.0