From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: stephen@networkplumber.org, hkalra@marvell.com,
anatoly.burakov@intel.com, stable@dpdk.org,
Sriram Yagnaraman <sriram.yagnaraman@ericsson.com>,
Jakub Grajciar <jgrajcia@cisco.com>,
Ferruh Yigit <ferruh.yigit@amd.com>
Subject: [PATCH v2 06/12] net/memif: fix some interrupt FD leaks
Date: Sat, 24 Oct 2026 15:21:31 +0200 [thread overview]
Message-ID: <20261024132138.7239-7-david.marchand@redhat.com> (raw)
In-Reply-To: <20261024132138.7239-1-david.marchand@redhat.com>
Fix several resource leaks in error handling and cleanup paths:
In memif_socket_create(), when rte_intr_callback_register() fails,
return via error path instead of returning directly, ensuring sockfd,
sock and intr_handle are properly cleaned up.
In memif_socket_init(), when rte_hash_add_key_data() fails, clean up
the newly created socket including unregistering callback, closing fd
and freeing intr_handle for listener sockets.
In memif_socket_remove_device(), unregister the listener callback and
close the socket fd before freeing the interrupt handle.
Fixes: 09c7e63a71f9 ("net/memif: introduce memory interface PMD")
Cc: stable@dpdk.org
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
drivers/net/memif/memif_socket.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/net/memif/memif_socket.c b/drivers/net/memif/memif_socket.c
index 2d16decbef..bd52a95473 100644
--- a/drivers/net/memif/memif_socket.c
+++ b/drivers/net/memif/memif_socket.c
@@ -1051,7 +1051,7 @@ memif_socket_create(char *key, uint8_t listener, bool is_abstract, uid_t owner_u
if (ret < 0) {
MIF_LOG(ERR, "Failed to register interrupt "
"callback for listener socket");
- return NULL;
+ goto error;
}
}
@@ -1115,6 +1115,14 @@ memif_socket_init(struct rte_eth_dev *dev, const char *socket_filename)
ret = rte_hash_add_key_data(hash, key, socket);
if (ret < 0) {
MIF_LOG(ERR, "Failed to add socket to socket hash.");
+ if (socket->listener) {
+ rte_intr_callback_unregister(socket->intr_handle,
+ memif_listener_handler, socket);
+ close(rte_intr_fd_get(socket->intr_handle));
+ rte_intr_fd_set(socket->intr_handle, -1);
+ rte_intr_instance_free(socket->intr_handle);
+ }
+ rte_free(socket);
return ret;
}
}
@@ -1180,8 +1188,13 @@ memif_socket_remove_device(struct rte_eth_dev *dev)
MIF_LOG(ERR, "Failed to remove socket file: %s",
socket->filename);
}
- if (pmd->role != MEMIF_ROLE_CLIENT)
+ if (pmd->role != MEMIF_ROLE_CLIENT) {
+ rte_intr_callback_unregister(socket->intr_handle, memif_listener_handler,
+ socket);
+ close(rte_intr_fd_get(socket->intr_handle));
+ rte_intr_fd_set(socket->intr_handle, -1);
rte_intr_instance_free(socket->intr_handle);
+ }
rte_free(socket);
}
}
--
2.54.0
next prev parent reply other threads:[~2026-10-24 13:22 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 9:23 [PATCH 0/9] Interrupt fixes for leaks and warnings David Marchand
2026-10-21 9:23 ` [PATCH 1/9] eal/linux: fix FD leak in alarm subsystem David Marchand
2026-10-21 9:23 ` [PATCH 2/9] eal/linux: reset FD in interrupt handle for uevent David Marchand
2026-10-21 9:23 ` [PATCH 3/9] interrupts: do not duplicate interrupt handles David Marchand
2026-10-21 9:23 ` [PATCH 4/9] bus/pci: reset VFIO device FD after release David Marchand
2026-10-21 9:23 ` [PATCH 5/9] net/mana: reset FD in interrupt handle David Marchand
2026-10-21 9:23 ` [PATCH 6/9] net/memif: fix some interrupt FD leaks David Marchand
2026-10-21 9:23 ` [PATCH 7/9] net/memif: reset FD in interrupt handle David Marchand
2026-10-21 9:23 ` [PATCH 8/9] net/sxe2: " David Marchand
2026-10-21 9:23 ` [PATCH 9/9] raw/ifpga: " David Marchand
2026-10-24 13:21 ` [PATCH v2 00/12] Interrupt fixes for leaks and warnings David Marchand
2026-10-24 13:21 ` [PATCH v2 01/12] eal/linux: fix FD leak in alarm subsystem David Marchand
2026-10-24 13:21 ` [PATCH v2 02/12] eal/linux: reset FD in interrupt handle for uevent David Marchand
2026-10-24 14:07 ` Burakov, Anatoly
2026-10-24 13:21 ` [PATCH v2 03/12] interrupts: do not duplicate interrupt handles David Marchand
2026-10-24 14:11 ` Burakov, Anatoly
2026-10-26 15:39 ` David Marchand
2026-10-24 13:21 ` [PATCH v2 04/12] bus/pci: reset VFIO device FD after release David Marchand
2026-10-24 14:11 ` Burakov, Anatoly
2026-10-24 13:21 ` [PATCH v2 05/12] net/mana: reset FD in interrupt handle David Marchand
2026-10-24 13:21 ` David Marchand [this message]
2026-10-24 13:21 ` [PATCH v2 07/12] net/memif: " David Marchand
2026-10-24 13:21 ` [PATCH v2 08/12] net/sxe2: " David Marchand
2026-10-24 13:21 ` [PATCH v2 09/12] raw/ifpga: " David Marchand
2026-10-24 13:21 ` [PATCH v2 10/12] eal/linux: fix closing of event FDs not owned by EAL David Marchand
2026-10-24 13:21 ` [PATCH v2 11/12] eal/linux: fix eventfd leaks when enabling interrupts David Marchand
2026-10-24 13:21 ` [PATCH v2 12/12] interrupts: warn on leaked event FDs David Marchand
2026-10-27 17:16 ` [PATCH v2 00/12] Interrupt fixes for leaks and warnings David Marchand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261024132138.7239-7-david.marchand@redhat.com \
--to=david.marchand@redhat.com \
--cc=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=hkalra@marvell.com \
--cc=jgrajcia@cisco.com \
--cc=sriram.yagnaraman@ericsson.com \
--cc=stable@dpdk.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox