From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: [PATCH 3/3] virtio: fix possible NULL dereference Date: Fri, 28 Aug 2015 09:23:39 -0700 Message-ID: <1440779019-10793-4-git-send-email-stephen@networkplumber.org> References: <1440779019-10793-1-git-send-email-stephen@networkplumber.org> Cc: dev@dpdk.org To: huawei.xie@intel.com, changchun.ouyang@intel.com Return-path: Received: from mail-pa0-f48.google.com (mail-pa0-f48.google.com [209.85.220.48]) by dpdk.org (Postfix) with ESMTP id 3D34A8D89 for ; Fri, 28 Aug 2015 18:23:34 +0200 (CEST) Received: by pabzx8 with SMTP id zx8so67500146pab.1 for ; Fri, 28 Aug 2015 09:23:33 -0700 (PDT) In-Reply-To: <1440779019-10793-1-git-send-email-stephen@networkplumber.org> 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" Found by Coverity. In virtio_dev_queue_release if the queue pointer is NULL, then driver is dereferencing it to get hw pointer. Also, don't do useless assignment Signed-off-by: Stephen Hemminger --- drivers/net/virtio/virtio_ethdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 338d891..914c73d 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -239,15 +239,15 @@ virtio_set_multiple_queues(struct rte_eth_dev *dev, uint16_t nb_queues) void virtio_dev_queue_release(struct virtqueue *vq) { - struct virtio_hw *hw = vq->hw; if (vq) { + struct virtio_hw *hw = vq->hw; + /* Select and deactivate the queue */ VIRTIO_WRITE_REG_2(hw, VIRTIO_PCI_QUEUE_SEL, vq->queue_id); VIRTIO_WRITE_REG_4(hw, VIRTIO_PCI_QUEUE_PFN, 0); rte_free(vq); - vq = NULL; } } -- 2.1.4