Return-Path: From: Sven Eckelmann Date: Tue, 17 Jun 2014 21:56:01 +0200 Message-Id: <1403034964-6737-4-git-send-email-sven@narfation.org> In-Reply-To: <1403034964-6737-1-git-send-email-sven@narfation.org> References: <1403034964-6737-1-git-send-email-sven@narfation.org> Subject: [B.A.T.M.A.N.] [PATCH 4/7] batmand: Free socket when setsockopt failed Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: b.a.t.m.a.n@lists.open-mesh.org Cc: Sven Eckelmann client_to_gw_tun calls setsockopt which can fail. In this case it jumps to the error handling and cleanup code but doesn't close the udp_sock. This has to be done to avoid leaking of file descriptors. Signed-off-by: Sven Eckelmann --- posix/tunnel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/posix/tunnel.c b/posix/tunnel.c index 08c56a2..8e7611b 100644 --- a/posix/tunnel.c +++ b/posix/tunnel.c @@ -201,7 +201,7 @@ void *client_to_gw_tun(void *arg) sock_opts = 1; if (setsockopt(udp_sock, SOL_SOCKET, SO_REUSEADDR, &sock_opts, sizeof(sock_opts)) < 0) { debug_output(0, "Error - can't set options on udp socket: %s\n", strerror(errno)); - goto out; + goto udp_out; } if (bind(udp_sock, (struct sockaddr *)&my_addr, sizeof(struct sockaddr_in)) < 0) { -- 2.0.0