[PATCH] net/memif: unregister callback on error in listener handler
Dmitriy Matveichev
matveichev.dmitriy at gmail.com
Thu Aug 6 16:03:33 CEST 2026
Fix the crash if a memif client disconnects before a server says hello
Signed-off-by: Dmitriy Matveichev <matveichev.dmitriy at gmail.com>
---
If a memif client disconnects before a server says hello in memif_listener_handler we get errors
"MEMIF: memif_msg_send_from_queue(): sendmsg fail: Broken pipe.
EAL: PANIC in eal_intr_thread_main():
Error adding fd 59 epoll_ctl, Bad file descriptor".
During the error handling in this func a socket is freed but the eal_intr_thread_main knows nothing about it. The descriptor becomes invalid after close.
We should unregister callback from the eal_intr_thread_main loop and only after that we can safely free the socket.
.mailmap | 1 +
drivers/net/memif/memif_socket.c | 10 ++++++----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/.mailmap b/.mailmap
index fcb3d1bb3f..d0148b0d9c 100644
--- a/.mailmap
+++ b/.mailmap
@@ -409,6 +409,7 @@ Ding Zhi <zhi.ding at 6wind.com>
Diogo Behrens <diogo.behrens at huawei.com>
Dirk-Holger Lenz <dirk.lenz at ng4t.com>
Dmitri Epshtein <dima at marvell.com>
+Dmitriy Matveichev <matveichev.dmitriy at gmail.com>
Dmitriy Yakovlev <bombermag at gmail.com>
Dmitry Eremin-Solenikov <dmitry.ereminsolenikov at linaro.org>
Dmitry Kozlyuk <dmitry.kozliuk at gmail.com> <dkozlyuk at nvidia.com>
diff --git a/drivers/net/memif/memif_socket.c b/drivers/net/memif/memif_socket.c
index 649f8d0e61..898ad75fa6 100644
--- a/drivers/net/memif/memif_socket.c
+++ b/drivers/net/memif/memif_socket.c
@@ -878,14 +878,16 @@ memif_listener_handler(void *arg)
return;
error:
- if (sockfd >= 0) {
- close(sockfd);
- sockfd = -1;
- }
if (cc != NULL) {
+ rte_intr_callback_unregister(cc->intr_handle, memif_intr_handler,
+ cc);
rte_intr_instance_free(cc->intr_handle);
rte_free(cc);
}
+ if (sockfd >= 0) {
+ close(sockfd);
+ sockfd = -1;
+ }
}
static struct memif_socket *
--
2.53.0
More information about the dev
mailing list