net/virtio: fix memory leak in dev close

Message ID 20210725020315.15010-1-clgx0086@163.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series net/virtio: fix memory leak in dev close |

Checks

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

Commit Message

Gaoxiang Liu July 25, 2021, 2:03 a.m. UTC
  Free the "intr_handle" memory in virtio_user_dev_uninit() to
avoid memory leak.
when virtio user dev closes, the "intr_handle" memory is not freeed
that is alloced in virtio_user_fill_intr_handle().

Fixes: 7f468b2ebfad ("net/virtio: release port upon close")

Signed-off-by: Gaoxiang Liu <liugaoxiang@huawei.com>
---
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 7 +++++++
 1 file changed, 7 insertions(+)
  

Comments

Chenbo Xia July 26, 2021, 8:42 a.m. UTC | #1
Hi Gaoxiang,

> -----Original Message-----
> From: Gaoxiang Liu <clgx0086@163.com>
> Sent: Sunday, July 25, 2021 10:03 AM
> To: Maxime Coquelin <maxime.coquelin@redhat.com>; Xia, Chenbo
> <chenbo.xia@intel.com>
> Cc: dev@dpdk.org; liugaoxiang@huawei.com; Gaoxiang Liu <clgx0086@163.com>
> Subject: [PATCH] net/virtio: fix memory leak in dev close

I suggest the title: fix memory leak of interrupt handle

> 
> Free the "intr_handle" memory in virtio_user_dev_uninit() to
> avoid memory leak.
> when virtio user dev closes, the "intr_handle" memory is not freeed
> that is alloced in virtio_user_fill_intr_handle().

I suggest to replace 'intr_handle memory' with 'memory of interrupt handle'

freeed -> freed

alloced -> allocated

> 
> Fixes: 7f468b2ebfad ("net/virtio: release port upon close")

Please add cc stable tag under fixes line:
Cc: stable@dpdk.org

And I think the fix commit id is not correct. Fix commit id should be the
first commit that introduces the bug. I think it's:

3d4fb6fd2505 ("net/virtio-user: support Rx interrupt")

Please help me double confirm.

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

I suggest to send patch using this email too.

The patch content looks good to me.
Thanks,
Chenbo

> ---
>  drivers/net/virtio/virtio_user/virtio_user_dev.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> index 1cd1e95f4..16c58710d 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> @@ -654,6 +654,13 @@ virtio_user_dev_init(struct virtio_user_dev *dev,
> char *path, int queues,
>  void
>  virtio_user_dev_uninit(struct virtio_user_dev *dev)
>  {
> +	struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->hw.port_id];
> +
> +	if (eth_dev->intr_handle) {
> +		free(eth_dev->intr_handle);
> +		eth_dev->intr_handle = NULL;
> +	}
> +
>  	virtio_user_stop_device(dev);
> 
>  	rte_mem_event_callback_unregister(VIRTIO_USER_MEM_EVENT_CLB_NAME,
> dev);
> --
> 2.32.0
  
Gaoxiang Liu July 26, 2021, 11:38 a.m. UTC | #2
>Hi, chen bo
>>And I think the fix commit id is not correct. Fix commit id should be the
>>first commit that introduces the bug. I think it's:
>>3d4fb6fd2505 ("net/virtio-user: support Rx interrupt")
> Yes, it should be the commit id. And I will fix other issues right now.
> Thanks.




At 2021-07-26 16:42:57, "Xia, Chenbo" <chenbo.xia@intel.com> wrote:
>Hi Gaoxiang,
>
>> -----Original Message-----
>> From: Gaoxiang Liu <clgx0086@163.com>
>> Sent: Sunday, July 25, 2021 10:03 AM
>> To: Maxime Coquelin <maxime.coquelin@redhat.com>; Xia, Chenbo
>> <chenbo.xia@intel.com>
>> Cc: dev@dpdk.org; liugaoxiang@huawei.com; Gaoxiang Liu <clgx0086@163.com>
>> Subject: [PATCH] net/virtio: fix memory leak in dev close
>
>I suggest the title: fix memory leak of interrupt handle
>
>> 
>> Free the "intr_handle" memory in virtio_user_dev_uninit() to
>> avoid memory leak.
>> when virtio user dev closes, the "intr_handle" memory is not freeed
>> that is alloced in virtio_user_fill_intr_handle().
>
>I suggest to replace 'intr_handle memory' with 'memory of interrupt handle'
>
>freeed -> freed
>
>alloced -> allocated
>
>> 
>> Fixes: 7f468b2ebfad ("net/virtio: release port upon close")
>
>Please add cc stable tag under fixes line:
>Cc: stable@dpdk.org
>
>And I think the fix commit id is not correct. Fix commit id should be the
>first commit that introduces the bug. I think it's:
>
>3d4fb6fd2505 ("net/virtio-user: support Rx interrupt")
>
>Please help me double confirm.
>
>> 
>> Signed-off-by: Gaoxiang Liu <liugaoxiang@huawei.com>
>
>I suggest to send patch using this email too.
>
>The patch content looks good to me.
>Thanks,
>Chenbo
>
>> ---
>>  drivers/net/virtio/virtio_user/virtio_user_dev.c | 7 +++++++
>>  1 file changed, 7 insertions(+)
>> 
>> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c
>> b/drivers/net/virtio/virtio_user/virtio_user_dev.c
>> index 1cd1e95f4..16c58710d 100644
>> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
>> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
>> @@ -654,6 +654,13 @@ virtio_user_dev_init(struct virtio_user_dev *dev,
>> char *path, int queues,
>>  void
>>  virtio_user_dev_uninit(struct virtio_user_dev *dev)
>>  {
>> +	struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->hw.port_id];
>> +
>> +	if (eth_dev->intr_handle) {
>> +		free(eth_dev->intr_handle);
>> +		eth_dev->intr_handle = NULL;
>> +	}
>> +
>>  	virtio_user_stop_device(dev);
>> 
>>  	rte_mem_event_callback_unregister(VIRTIO_USER_MEM_EVENT_CLB_NAME,
>> dev);
>> --
>> 2.32.0
  

Patch

diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 1cd1e95f4..16c58710d 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -654,6 +654,13 @@  virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
 void
 virtio_user_dev_uninit(struct virtio_user_dev *dev)
 {
+	struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->hw.port_id];
+
+	if (eth_dev->intr_handle) {
+		free(eth_dev->intr_handle);
+		eth_dev->intr_handle = NULL;
+	}
+
 	virtio_user_stop_device(dev);
 
 	rte_mem_event_callback_unregister(VIRTIO_USER_MEM_EVENT_CLB_NAME, dev);