All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net/virtio-user: fix interrupt handle cleanup
@ 2026-12-03  8:12 Xiao Liang
  0 siblings, 0 replies; only message in thread
From: Xiao Liang @ 2026-12-03  8:12 UTC (permalink / raw)
  To: Maxime Coquelin, Chenbo Xia; +Cc: dev, stable, Anatoly Burakov

Clear event FDs before freeing the interrupt handle to avoid false leak
warnings since 67813957d876 ("interrupts: warn on leaked event FDs").

Use the same cleanup on dev init failure, so the allocated handle is
released.

Fixes: 3d4fb6fd2505 ("net/virtio-user: support Rx interrupt")
Cc: stable@dpdk.org
Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
---
 .../net/virtio/virtio_user/virtio_user_dev.c  | 27 ++++++++++++++++---
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index c38ac059df..bf2e6e9d76 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -582,6 +582,27 @@ virtio_user_fill_intr_handle(struct virtio_user_dev *dev)
 	return 0;
 }
 
+static void
+virtio_user_free_intr_handle(struct rte_eth_dev *eth_dev)
+{
+	struct rte_intr_handle *intr_handle = eth_dev->intr_handle;
+	int i, nb_intr;
+
+	if (intr_handle == NULL)
+		return;
+
+	/* fd is not owned by the driver, only clear reference here. */
+	rte_intr_fd_set(intr_handle, -1);
+
+	/* Clear event FD references before freeing the interrupt handle. */
+	nb_intr = rte_intr_nb_intr_get(intr_handle);
+	for (i = 0; i < nb_intr; i++)
+		rte_intr_efds_index_set(intr_handle, i, -1);
+
+	rte_intr_instance_free(intr_handle);
+	eth_dev->intr_handle = NULL;
+}
+
 static void
 virtio_user_mem_event_cb(enum rte_mem_event type __rte_unused,
 			 const void *addr,
@@ -893,6 +914,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, uint16_t queues,
 	return 0;
 
 notify_uninit:
+	virtio_user_free_intr_handle(&rte_eth_devices[dev->hw.port_id]);
 	virtio_user_dev_uninit_notify(dev);
 free_vrings:
 	virtio_user_free_vrings(dev);
@@ -907,10 +929,7 @@ virtio_user_dev_uninit(struct virtio_user_dev *dev)
 {
 	struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->hw.port_id];
 
-	/* fd is not owned by the driver, only clear reference here. */
-	rte_intr_fd_set(eth_dev->intr_handle, -1);
-	rte_intr_instance_free(eth_dev->intr_handle);
-	eth_dev->intr_handle = NULL;
+	virtio_user_free_intr_handle(eth_dev);
 
 	virtio_user_stop_device(dev);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-04 14:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03  8:12 [PATCH] net/virtio-user: fix interrupt handle cleanup Xiao Liang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.