Skip to contentSkip to conversation

virtio: fixed segmentation fault in queue_release

PATCH In review Bernard Iremonger 3 participants 4 messages Oct 20, 2015 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 virtio: fixed segmentation fault in queue_release

if input parameter vq is NULL, hw = vq->hw, causes a segmentation fault.

---
 drivers/net/virtio/virtio_ethdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/virtio/virtio_ethdev.c +2 -1
index 465d3cd..147aca1 100644
@@ -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);
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/2 rel_notes: update for fix for virtio segmentation fault

---
 doc/guides/rel_notes/release_2_2.rst | 3 +++
 1 file changed, 3 insertions(+)
doc/guides/rel_notes/release_2_2.rst +3 -0
index 5687676..7e8bd4f 100644
@@ -39,6 +39,9 @@ Drivers
 
   Fixed issue with libvirt ``virsh destroy`` not killing the VM.
 
+* **virtio: Fixed segmentation fault in queue_release.**
+
+  Fixed issue with virtio_dev_queue_release function when vq parameter was NULL.
 
 Libraries
 ~~~~~~~~~
Signature · 1 line
1.9.1
Acked-by on v1 1/2
#2 lore raw
In reply to Bernard Iremonger
Quoted 13 lines · On Tue, 20 Oct 2015 16:37:41 +0100 Bernard Iremonger…

if input parameter vq is NULL, hw = vq->hw, causes a segmentation fault.

---
 drivers/net/virtio/virtio_ethdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 465d3cd..147aca1 100644
@@ -239,9 +239,10 @@ virtio_set_multiple_queues(struct rte_eth_dev *dev, uint16_t nb_queues)
 

drivers/net/virtio/virtio_ethdev.c virtio_set_multiple_queues(struct rte_eth_dev *dev, uint16_t nb_queues) · line 248

Quoted 10 lines
drivers/net/virtio/virtio_ethdev.c +2 -1
 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);

This could only happen for the case of the control vq. Others are guaranteed to be non NULL by rte_ethdev.