From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yuanhan Liu Subject: [PATCH] vhost: fix coverity defect Date: Tue, 5 Apr 2016 14:00:43 +0800 Message-ID: <1459836043-18863-1-git-send-email-yuanhan.liu@linux.intel.com> Cc: huawei.xie@intel.com, Thomas Monjalon , Yuanhan Liu To: dev@dpdk.org 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) List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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