[v4] net/virtio: fix repeated memory free of vq

Message ID 20210831143951.93-1-gaoxiangliu0@163.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series [v4] net/virtio: fix repeated memory free of vq |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/github-robot: build success github build: passed
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Gaoxiang Liu Aug. 31, 2021, 2:39 p.m. UTC
  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")
Cc: stable@dpdk.org

Signed-off-by: Gaoxiang Liu <liugaoxiang@huawei.com>
---

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(+)
  

Comments

Gaoxiang Liu Sept. 7, 2021, 3:41 a.m. UTC | #1
Hi, chenbo, maxime.
Please help to review the patch.
The patch has been proposed a month ago.


At 2021-08-31 22:39:51, "Gaoxiang Liu" <gaoxiangliu0@163.com> 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 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")
>Cc: stable@dpdk.org
>
>Signed-off-by: Gaoxiang Liu <liugaoxiang@huawei.com>
>---
>
>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(+)
>
>diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
>index 056830566..fc72d71cb 100644
>--- a/drivers/net/virtio/virtio_ethdev.c
>+++ b/drivers/net/virtio/virtio_ethdev.c
>@@ -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
  
Chenbo Xia Sept. 7, 2021, 5:08 a.m. UTC | #2
> -----Original Message-----
> From: Gaoxiang Liu <gaoxiangliu0@163.com>
> Sent: Tuesday, August 31, 2021 10:40 PM
> To: maxime.coquelin@redhat.com; Xia, Chenbo <chenbo.xia@intel.com>
> Cc: dev@dpdk.org; liugaoxiang@huawei.com; Gaoxiang Liu <gaoxiangliu0@163.com>;
> stable@dpdk.org
> 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")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Gaoxiang Liu <liugaoxiang@huawei.com>
> ---
> 
> 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(+)
> 
> diff --git a/drivers/net/virtio/virtio_ethdev.c
> b/drivers/net/virtio/virtio_ethdev.c
> index 056830566..fc72d71cb 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -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

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

For this patch:

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
  
Maxime Coquelin Sept. 14, 2021, 11:27 a.m. UTC | #3
On 8/31/21 4:39 PM, 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 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")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Gaoxiang Liu <liugaoxiang@huawei.com>
> ---
> 
> 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(+)
> 


Applied to dpdk-next-virtio/main.

Thanks,
Maxime
  

Patch

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 056830566..fc72d71cb 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -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;
 }