[PATCH 02/13] ipaccess: fix leak of e1inp_line

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

pablo at gnumonks.org pablo at gnumonks.org
Thu Aug 23 22:44:51 UTC 2012


From: Pablo Neira Ayuso <pablo at gnumonks.org>

Holger reported a leak in the ipaccess_drop path and a patch to
fix this. This is a new version of the patch posted that also
handle the case in which only one of the link (OML / RSL) is
established and no ID_RESP was received.

Based on patch of Holger Freyther.
---
 src/e1_input.c       |    1 +
 src/input/hsl.c      |    3 ---
 src/input/ipaccess.c |   10 ++++------
 3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/e1_input.c b/src/e1_input.c
index 957b74c..a85dd91 100644
--- a/src/e1_input.c
+++ b/src/e1_input.c
@@ -486,6 +486,7 @@ void e1inp_sign_link_destroy(struct e1inp_sign_link *link)
 	if (link->ts->line->driver->close)
 		link->ts->line->driver->close(link);
 
+	e1inp_line_put(link->ts->line);
 	talloc_free(link);
 }
 
diff --git a/src/input/hsl.c b/src/input/hsl.c
index 3dcba1d..1a60c2b 100644
--- a/src/input/hsl.c
+++ b/src/input/hsl.c
@@ -83,9 +83,6 @@ static void hsl_drop(struct e1inp_line *line, struct osmo_fd *bfd)
 		close(bfd->fd);
 		bfd->fd = -1;
 	}
-	/* put the virtual E1 line that we cloned for this socket, if
-	 * it becomes unused, it gets released. */
-	e1inp_line_put(line);
 }
 
 static int process_hsl_rsl(struct msgb *msg, struct e1inp_line *line,
diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c
index 76d1994..a3c3b70 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -237,9 +237,6 @@ static int ipaccess_drop(struct osmo_fd *bfd)
 	int ret = 0;
 	struct e1inp_line *line = bfd->data;
 
-	/* e1inp_sign_link_destroy releases the socket descriptors for us. */
-	line->ops->sign_link_down(line);
-
 	/* Error case: we did not see any ID_RESP yet for this socket. */
 	if (bfd->fd != -1) {
 		LOGP(DLINP, LOGL_ERROR, "Forcing socket shutdown with "
@@ -249,9 +246,10 @@ static int ipaccess_drop(struct osmo_fd *bfd)
 		bfd->fd = -1;
 		ret = -ENOENT;
 	}
-	/* put the virtual E1 line that we cloned for this socket, if
-	 * it becomes unused, it gets released. */
-	e1inp_line_put(line);
+
+	/* e1inp_sign_link_destroy releases the socket descriptors for us. */
+	line->ops->sign_link_down(line);
+
 	return ret;
 }
 
-- 
1.7.10.4





More information about the OpenBSC mailing list