Change in libosmo-abis[master]: ipaccess: e1inp_ipa_bts_rsl_connect: Fix memleak recreating ipa_clien...

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/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Mon Oct 11 10:19:20 UTC 2021


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-abis/+/25742 )


Change subject: ipaccess: e1inp_ipa_bts_rsl_connect: Fix memleak recreating ipa_client_conn
......................................................................

ipaccess: e1inp_ipa_bts_rsl_connect: Fix memleak recreating ipa_client_conn

If BTS, using this app, tried to use it in order to re-create the
connection, it would leak the previous strut ipa_client_conn. A similar
fix was already put in place recently for OML, but it was not applied
for RSL.

The leak was spotted by having a BTS connecting fine over OMl but then
failing each time to connect on RSL.

Related: OS#5248
Change-Id: I4ee1ae318b446490783c8b910fca10ba5f72dd5a
---
M src/input/ipaccess.c
1 file changed, 19 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/42/25742/1

diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c
index 63461a2..04b4474 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -1005,7 +1005,7 @@
 
 struct ipaccess_line {
 	bool line_already_initialized;
-	struct ipa_client_conn *ipa_cli;
+	struct ipa_client_conn *ipa_cli[NUM_E1_TS]; /* 0=OML, 1+N=TRX_N */
 };
 
 static int ipaccess_line_update(struct e1inp_line *line)
@@ -1078,10 +1078,10 @@
 		     IPA_TCP_PORT_OML);
 
 		/* Drop previous line */
-		if (il->ipa_cli) {
-			ipa_client_conn_close(il->ipa_cli);
-			ipa_client_conn_destroy(il->ipa_cli);
-			il->ipa_cli = NULL;
+		if (il->ipa_cli[0]) {
+			ipa_client_conn_close(il->ipa_cli[0]);
+			ipa_client_conn_destroy(il->ipa_cli[0]);
+			il->ipa_cli[0] = NULL;
 		}
 
 		link = ipa_client_conn_create2(tall_ipa_ctx,
@@ -1111,7 +1111,7 @@
 
 		e1i_ts = e1inp_line_ipa_oml_ts(line);
 		ipaccess_bts_keepalive_fsm_alloc(e1i_ts, link, "oml_bts_to_bsc");
-		il->ipa_cli = link;
+		il->ipa_cli[0] = link;
 		ret = 0;
 		break;
 	}
@@ -1137,6 +1137,7 @@
 {
 	struct ipa_client_conn *rsl_link;
 	struct e1inp_ts *e1i_ts = e1inp_line_ipa_rsl_ts(line, trx_nr);
+	struct ipaccess_line *il;
 
 	if (E1INP_SIGN_RSL+trx_nr-1 >= NUM_E1_TS) {
 		LOGP(DLINP, LOGL_ERROR, "cannot create RSL BTS link: "
@@ -1144,6 +1145,17 @@
 		return -EINVAL;
 	}
 
+	if (!line->driver_data)
+		line->driver_data = talloc_zero(line, struct ipaccess_line);
+	il = line->driver_data;
+
+	/* Drop previous line */
+	if (il->ipa_cli[1 + trx_nr]) {
+		ipa_client_conn_close(il->ipa_cli[1 + trx_nr]);
+		ipa_client_conn_destroy(il->ipa_cli[1 + trx_nr]);
+		il->ipa_cli[1 + trx_nr] = NULL;
+	}
+
 	rsl_link = ipa_client_conn_create2(tall_ipa_ctx,
 					  e1inp_line_ipa_rsl_ts(line, trx_nr),
 					  E1INP_SIGN_RSL+trx_nr,
@@ -1167,8 +1179,8 @@
 		ipa_client_conn_destroy(rsl_link);
 		return -EIO;
 	}
-
 	ipaccess_bts_keepalive_fsm_alloc(e1i_ts, rsl_link, "rsl_bts_to_bsc");
+	il->ipa_cli[1 + trx_nr] = rsl_link;
 	return 0;
 }
 

-- 
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/25742
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: I4ee1ae318b446490783c8b910fca10ba5f72dd5a
Gerrit-Change-Number: 25742
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211011/5d92fc4b/attachment.htm>


More information about the gerrit-log mailing list