On Wed, Aug 22, 2012 at 05:04:44PM +0200, [email protected] wrote:
> From: Pablo Neira Ayuso <[email protected]>
> 
> Holger reported a leak in the ipaccess_drop path.

New version of this patch, this time based on Holger's plus handling
the case in which no full OML / RSL has been established.
>From 2027a327bce52a7cd568f91576c836b54e9d8e77 Mon Sep 17 00:00:00 2001
From: Pablo Neira Ayuso <[email protected]>
Date: Wed, 22 Aug 2012 13:57:58 +0200
Subject: [PATCH] ipaccess: fix leak of e1inp_line

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

Reply via email to