[PATCH] 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 Neira Ayuso pablo at gnumonks.org
Wed Aug 22 11:57:58 UTC 2012


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      |    4 +---
 src/input/ipaccess.c |    4 +---
 3 files changed, 3 insertions(+), 6 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..b86d7f6 100644
--- a/src/input/hsl.c
+++ b/src/input/hsl.c
@@ -82,10 +82,8 @@ static void hsl_drop(struct e1inp_line *line, struct osmo_fd *bfd)
 		osmo_fd_unregister(bfd);
 		close(bfd->fd);
 		bfd->fd = -1;
+		e1inp_line_put(line);
 	}
-	/* 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..4c50640 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -248,10 +248,8 @@ static int ipaccess_drop(struct osmo_fd *bfd)
 		close(bfd->fd);
 		bfd->fd = -1;
 		ret = -ENOENT;
+		e1inp_line_put(line);
 	}
-	/* put the virtual E1 line that we cloned for this socket, if
-	 * it becomes unused, it gets released. */
-	e1inp_line_put(line);
 	return ret;
 }
 
-- 
1.7.10.4


--OgqxwSJOaUobr8KG--




More information about the OpenBSC mailing list