diff mbox series

net/virtio: fix memory leak of interrupt handle

Message ID 20210726115951.92-1-clgx0086@163.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers show
Series net/virtio: fix memory leak of interrupt handle | expand

Checks

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

Commit Message

Gaoxiang Liu July 26, 2021, 11:59 a.m. UTC
Free memory of interrupt handle in virtio_user_dev_uninit() to
avoid memory leak.
when virtio user dev closes, the "intr_handle" memory is not freed
that is allocated in virtio_user_fill_intr_handle().

Fixes: 3d4fb6fd2505 <"net/virtio-user: support Rx interrupt">

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

Comments

Maxime Coquelin July 26, 2021, 12:54 p.m. UTC | #1
On 7/26/21 1:59 PM, Gaoxiang Liu wrote:
> Free memory of interrupt handle in virtio_user_dev_uninit() to
> avoid memory leak.
> when virtio user dev closes, the "intr_handle" memory is not freed
> that is allocated in virtio_user_fill_intr_handle().
> 
> Fixes: 3d4fb6fd2505 <"net/virtio-user: support Rx interrupt">
> 
> Signed-off-by: Gaoxiang Liu <clgx0086@163.com>
> ---
>  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);
> 


Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
diff mbox series

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);