Thread (9 messages) 9 messages, 3 authors, 2021-07-28

Re: [dpdk-dev] [PATCH] net/virtio: fix memory leak in dev close

From: Xia, Chenbo <hidden>
Date: 2021-07-26 08:43:06

Hi Gaoxiang,
-----Original Message-----
From: Gaoxiang Liu <redacted>
Sent: Sunday, July 25, 2021 10:03 AM
To: Maxime Coquelin <redacted>; Xia, Chenbo
[off-list ref]
Cc: dev@dpdk.org; liugaoxiang@huawei.com; Gaoxiang Liu <redacted>
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 <redacted>
I suggest to send patch using this email too.

The patch content looks good to me.
Thanks,
Chenbo
quoted hunk ↗ jump to hunk
---
 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
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help