Skip to contentSkip to conversation

net/virtio: fix repeated memory free of vq

PATCH Superseded Gaoxiang Liu 3 participants 8 messages Aug 3, 2021 – Sep 14, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net/virtio: fix repeated memory free of vq

When virtio_init_queue returns error, the memory of vq is freed. But the value of hw->vqs[queue_idx] does not restore. If hw->vqs[queue_idx] != NULL, the memory of vq is freed again in virtio_free_queues.

Fixes 69c80d4ef89b ("net/virtio: allocate queue at init stage")
---
 drivers/net/virtio/virtio_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/virtio/virtio_ethdev.c +1 -0
index 056830566..fc72d71cb 100644
@@ -631,6 +631,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)
 	rte_memzone_free(mz);
 free_vq:
 	rte_free(vq);
+	hw->vqs[queue_idx] = NULL;
 
 	return ret;
 }
Signature · 1 line
2.32.0
#1 lore raw

PATCH v2 1/1 net/virtio: fix repeated memory free of vq

When virtio_init_queue returns error, the memory of vq is freed. But the value of hw->vqs[queue_idx] does not restore. If hw->vqs[queue_idx] != NULL, the memory of vq is freed again in virtio_free_queues.

Fixes 69c80d4ef89b ("net/virtio: allocate queue at init stage")

v2:
fix spelling warning

---
 drivers/net/virtio/virtio_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/virtio/virtio_ethdev.c +1 -0
index 056830566..fc72d71cb 100644
@@ -631,6 +631,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)
 	rte_memzone_free(mz);
 free_vq:
 	rte_free(vq);
+	hw->vqs[queue_idx] = NULL;
 
 	return ret;
 }
Signature · 1 line
2.32.0
#2 lore raw

On 08/04/2021 07:45, Gaoxiang Liu wrote:
When virtio_init_queue returns error, the memory of vq is freed. But the value of hw->vqs[queue_idx] does not restore. If hw->vqs[queue_idx] != NULL, the memory of vq is freed again in virtio_free_queues.

Fixes 69c80d4ef89b ("net/virtio: allocate queue at init stage")

v2:
fix spelling warning
---
drivers/net/virtio/virtio_ethdev.c | 1 +

1 file changed, 1 insertion(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 056830566..fc72d71cb 100644
@@ -631,6 +631,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)
     rte_memzone_free(mz);

free_vq:

     rte_free(vq);

+ hw->vqs[queue_idx] = NULL;

     return ret;
}

--
2.32.0

#3 lore raw

PATCH v3 1/1 net/virtio: fix repeated memory free of vq

In reply to Gaoxiang Liu

When virtio_init_queue returns error, the memory of vq is freed. But the value of hw->vqs[queue_idx] does not restore.
If virtio_init_queue returns error, the memory of vq is freed again in virtio_free_queues.

Fixes 69c80d4ef89b ("net/virtio: allocate queue at init stage")

---

v2:
* Fix spelling warning

v3:
* Add detailed log

---
 drivers/net/virtio/virtio_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/virtio/virtio_ethdev.c +1 -0
index 056830566..fc72d71cb 100644
@@ -631,6 +631,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)
 	rte_memzone_free(mz);
 free_vq:
 	rte_free(vq);
+	hw->vqs[queue_idx] = NULL;
 
 	return ret;
 }
Signature · 1 line
2.32.0
#4 lore raw

PATCH v4 1/1 net/virtio: fix repeated memory free of vq

When virtio_init_queue returns error, the memory of vq is freed. But the value of hw->vqs[queue_idx] does not restore.
If virtio_init_queue returns error, the memory of vq is freed again in virtio_free_queues.

Fixes 69c80d4ef89b ("net/virtio: allocate queue at init stage")

---

v2:
* Fix spelling warning

v3:
* Add detailed log

v4:
* Update the email address

---
 drivers/net/virtio/virtio_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/virtio/virtio_ethdev.c +1 -0
index 056830566..fc72d71cb 100644
@@ -631,6 +631,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)
 	rte_memzone_free(mz);
 free_vq:
 	rte_free(vq);
+	hw->vqs[queue_idx] = NULL;
 
 	return ret;
 }
Signature · 1 line
2.32.0
#5 lore raw

Hi, chenbo, maxime.
Please help to review the patch.
The patch has been proposed a month ago.

Quoted 37 lines · Gaoxiang Liu

When virtio_init_queue returns error, the memory of vq is freed. But the value of hw->vqs[queue_idx] does not restore.
If virtio_init_queue returns error, the memory of vq is freed again in virtio_free_queues.

Fixes 69c80d4ef89b ("net/virtio: allocate queue at init stage")

---

v2:
* Fix spelling warning

v3:
* Add detailed log

v4:
* Update the email address
---
drivers/net/virtio/virtio_ethdev.c | 1 +

1 file changed, 1 insertion(+)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 056830566..fc72d71cb 100644
@@ -631,6 +631,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)
 	rte_memzone_free(mz);

free_vq:

	rte_free(vq);
drivers/net/virtio/virtio_ethdev.c +1 -0
+	hw->vqs[queue_idx] = NULL;
	return ret;
}
Signature · 1 line
2.32.0
Reviewed-by on v4 1/1
#6 lore raw
In reply to Gaoxiang Liu
Quoted 44 lines

-----Original Message-----
From: Gaoxiang Liu <[email protected]>
Sent: Tuesday, August 31, 2021 10:40 PM
To: [email protected]; Xia, Chenbo <[email protected]>
Cc: [email protected]; [email protected]; Gaoxiang Liu <[email protected]>; [email protected]
Subject: [PATCH v4] net/virtio: fix repeated memory free of vq

When virtio_init_queue returns error, the memory of vq is freed. But the value of hw->vqs[queue_idx] does not restore.
If virtio_init_queue returns error, the memory of vq is freed again in virtio_free_queues.

Fixes 69c80d4ef89b ("net/virtio: allocate queue at init stage")

---

v2:
* Fix spelling warning

v3:
* Add detailed log

v4:
* Update the email address

---
 drivers/net/virtio/virtio_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/virtio/virtio_ethdev.c +1 -0
index 056830566..fc72d71cb 100644
@@ -631,6 +631,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t
 queue_idx)
 	rte_memzone_free(mz);
 free_vq:
 	rte_free(vq);
+	hw->vqs[queue_idx] = NULL;
 
 	return ret;
Quoted 3 lines

}
--
2.32.0

Better to make the author name and SOB tag use same email when applying.

For this patch:

#7 lore raw
In reply to Gaoxiang Liu
Quoted 14 lines · Gaoxiang Liu

When virtio_init_queue returns error, the memory of vq is freed. But the value of hw->vqs[queue_idx] does not restore.
If virtio_init_queue returns error, the memory of vq is freed again in virtio_free_queues.

Fixes 69c80d4ef89b ("net/virtio: allocate queue at init stage")

---

v2:
* Fix spelling warning

Quoted 9 lines

v3:
* Add detailed log

v4:
* Update the email address

---
 drivers/net/virtio/virtio_ethdev.c | 1 +
 1 file changed, 1 insertion(+)

Applied to dpdk-next-virtio/main.

Thanks,
Maxime