From ce8e121870d21e5ad5c6d1a21d0214e95e7a2fd2 Mon Sep 17 00:00:00 2001 From: Bernard Iremonger Date: Tue, 20 Oct 2015 16:37:41 +0100 Subject: [PATCH] virtio: fix crash when releasing null queue if input parameter vq is NULL, hw = vq->hw, causes a segmentation fault. Signed-off-by: Bernard Iremonger Acked-by: Stephen Hemminger --- doc/guides/rel_notes/release_2_2.rst | 4 ++++ drivers/net/virtio/virtio_ethdev.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/guides/rel_notes/release_2_2.rst b/doc/guides/rel_notes/release_2_2.rst index 9a35112e3c..4f75cff4b0 100644 --- a/doc/guides/rel_notes/release_2_2.rst +++ b/doc/guides/rel_notes/release_2_2.rst @@ -48,6 +48,10 @@ Drivers Fixed io permission in the interrupt handler. +* **virtio: Fixed crash when releasing queue.** + + Fixed issue when releasing null control queue. + Libraries ~~~~~~~~~ diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 465d3cde59..147aca1504 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -239,9 +239,10 @@ 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; + struct virtio_hw *hw; if (vq) { + 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); -- 2.20.1