Skip to contentSkip to conversation

net/memif: unregister callback on error in listener handler

PATCH Applied Dmitriy Matveichev 2 participants 2 messages Aug 6 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/memif: unregister callback on error in listener handler

Fix the crash if a memif client disconnects before a server says hello

---

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(-)
.mailmap +1 -0
index fcb3d1bb3f..d0148b0d9c 100644
@@ -409,6 +409,7 @@ Ding Zhi <[email protected]>
 Diogo Behrens <[email protected]>
 Dirk-Holger Lenz <[email protected]>
 Dmitri Epshtein <[email protected]>
+Dmitriy Matveichev <[email protected]>
 Dmitriy Yakovlev <[email protected]>
 Dmitry Eremin-Solenikov <[email protected]>
 Dmitry Kozlyuk <[email protected]> <[email protected]>
drivers/net/memif/memif_socket.c +6 -4
index 649f8d0e61..898ad75fa6 100644
@@ -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 *
Signature · 1 line
2.53.0