aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2021-10-11 12:14:36 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2021-10-11 12:16:30 +0200
commit92aee5109ccd0c5935eae898d6b54809dec0a92d (patch)
tree58eb1730df63d14a5638b1f1ef4fd60d8a7d9dbf
parentd2d28d83a437f7478a4dfff0c6cae5305801b881 (diff)
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
-rw-r--r--src/input/ipaccess.c26
1 files changed, 19 insertions, 7 deletions
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 @@ err:
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 @@ static int ipaccess_line_update(struct e1inp_line *line)
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 @@ static int ipaccess_line_update(struct e1inp_line *line)
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 @@ int e1inp_ipa_bts_rsl_connect_n(struct e1inp_line *line,
{
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 @@ int e1inp_ipa_bts_rsl_connect_n(struct e1inp_line *line,
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 @@ int e1inp_ipa_bts_rsl_connect_n(struct e1inp_line *line,
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;
}