Skip to contentSkip to conversation

net/virtio: Fix crash in virtio_dev_free_mbufs

PATCH Applied David C Harton 4 participants 4 messages Feb 3, 2018 – Feb 5, 2018 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/virtio: Fix crash in virtio_dev_free_mbufs

virtio_dev_free_mbufs was recently modified to free the virtqueues but failed to check whether the array was allocated. Added a check to ensure vqs was non-null.

Fixes bdb32afbb610 ("net/virtio: rationalize queue flushing")
---
 drivers/net/virtio/virtio_ethdev.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/virtio/virtio_ethdev.c +3 -0
index 2082d6a..884f74a 100644
@@ -1975,6 +1975,9 @@ static void virtio_dev_free_mbufs(struct rte_eth_dev *dev)
 	struct rte_mbuf *buf;
 	int queue_type;
 
+	if (hw->vqs == NULL)
+		return;
+
 	for (i = 0; i < nr_vq; i++) {
 		vq = hw->vqs[i];
 		if (!vq)
Signature · 1 line
2.10.3.dirty
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · David C Harton

virtio_dev_free_mbufs was recently modified to free the virtqueues but failed to check whether the array was allocated. Added a check to ensure vqs was non-null.

Fixes bdb32afbb610 ("net/virtio: rationalize queue flushing")

---

Thank you for this fix.
Out of curiosity, did you see the problem by code review or is there an easy way to reproduce the crash?

Reviewed-by on v1 1/1
#2 lore raw
In reply to David C Harton
Quoted 18 lines · David C Harton

virtio_dev_free_mbufs was recently modified to free the virtqueues but failed to check whether the array was allocated. Added a check to ensure vqs was non-null.

Fixes bdb32afbb610 ("net/virtio: rationalize queue flushing")
---
  drivers/net/virtio/virtio_ethdev.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 2082d6a..884f74a 100644

drivers/net/virtio/virtio_ethdev.c static void virtio_dev_free_mbufs(struct rte_eth_dev *dev) · line 1983

Quoted 9 lines
drivers/net/virtio/virtio_ethdev.c +3 -0
@@ -1975,6 +1975,9 @@ static void virtio_dev_free_mbufs(struct rte_eth_dev *dev)
  	struct rte_mbuf *buf;
  	int queue_type;
 
+	if (hw->vqs == NULL)
+		return;
+
  	for (i = 0; i < nr_vq; i++) {
  		vq = hw->vqs[i];
  		if (!vq)

Thanks,
Maxime

Reviewed-by Olivier Matz Reviewed-by Maxime Coquelin on v1 1/1 Applied
#3 lore raw
In reply to David C Harton
Quoted 8 lines · David C Harton

virtio_dev_free_mbufs was recently modified to free the virtqueues but failed to check whether the array was allocated. Added a check to ensure vqs was non-null.

Fixes bdb32afbb610 ("net/virtio: rationalize queue flushing")

[1] Signed-off-by: David Harton <[email protected]>

Applied to dpdk-next-net/master, thanks.

[1]
Hi David,

Since your previous commits has "David Harton" name, to prevent seen as a new person, I kept same name, fyi.