From a044bb6275492fbddbd0864e1820ccb08a70d107 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 21 Jul 2019 08:33:06 +0200 Subject: osmocon: Fix file descriptor + mem leak in error path Change-Id: I42ceed662889084783dc89f4ca39c3852428d108 Closes: CID#198539 --- src/host/osmocon/osmocon.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/host/osmocon') diff --git a/src/host/osmocon/osmocon.c b/src/host/osmocon/osmocon.c index 92372141..1bb0bb7d 100644 --- a/src/host/osmocon/osmocon.c +++ b/src/host/osmocon/osmocon.c @@ -1309,6 +1309,7 @@ static int tool_accept(struct osmo_fd *fd, unsigned int flags) con = talloc_zero(NULL, struct tool_connection); if (!con) { fprintf(stderr, "Failed to create tool connection.\n"); + close(rc); return -1; } @@ -1320,6 +1321,8 @@ static int tool_accept(struct osmo_fd *fd, unsigned int flags) con->fd.data = con; if (osmo_fd_register(&con->fd) != 0) { fprintf(stderr, "Failed to register the fd.\n"); + talloc_free(con); + close(rc); return -1; } -- cgit v1.2.3