[PATCH 1/3] alfred: don't leak event listener when epoll registration fails

Sven Eckelmann <[email protected]> Fri, 31 Jul 2026 08:44:19 +0200
Newsgroups org.open-mesh.lists.batman
Message-ID <[email protected]>
unix_sock_register_listener() allocated the event listener before adding
the client socket to the epoll instance. When epoll_ctl() failed, the error
path only closed the client socket and the listener allocation leaked.

Fixes: b106a7a36f98 ("alfred: notify event listener via unix socket")
Signed-off-by: Sven Eckelmann <[email protected]>
---
 unix_sock.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/unix_sock.c b/unix_sock.c
index e6b44da..07552a2 100644
--- a/unix_sock.c
+++ b/unix_sock.c
@@ -673,6 +673,7 @@ static int unix_sock_register_listener(struct globals *globals, int client_sock)
 	if (epoll_ctl(globals->epollfd, EPOLL_CTL_ADD, client_sock,
 		      &ev) == -1) {
 		perror("Failed to add epoll for event listener");
+		free(listener);
 		goto err;
 	}
 

-- 
2.47.3