diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2021-10-11 11:20:03 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2021-10-11 11:38:35 +0200 |
commit | 074672b6048ceca70cc3ebb9c1d0ba4c749a93c2 (patch) | |
tree | 1df1cd8d57c2d046d8d01b8f7faa45f14f4de69c | |
parent | 33b4b15f75bca787e917c227013e430668be351d (diff) |
Make sure lchan allocated memory from shadow_ts is properly freed
Since non-shadow TS are currently not allocated as talloc contexts,
lchan objects tend to allocate their own memory on trx talloc ctx
instead. That's fine for non-shadow TS, since the TS follow trx lifecycle
since they are part of the same talloc context. However, shadow TS are
recreated (re-allocated) each time the BTS reconnects, hence when htey
are freed we need to free substructs (lchan) memory in order to avoid it
being kept in trx talloc ctx.
Related: OS#5248
Change-Id: I73742535eb3c40a6866731acbff782940dab06c3
-rw-r--r-- | src/common/bts_trx.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/common/bts_trx.c b/src/common/bts_trx.c index b16a31c4..ff5c6181 100644 --- a/src/common/bts_trx.c +++ b/src/common/bts_trx.c @@ -115,12 +115,19 @@ void gsm_bts_trx_init_shadow_ts(struct gsm_bts_trx *trx) void gsm_bts_trx_free_shadow_ts(struct gsm_bts_trx *trx) { unsigned int tn; + unsigned int ln; for (tn = 0; tn < ARRAY_SIZE(trx->ts); tn++) { struct gsm_bts_trx_ts *shadow_ts = trx->ts[tn].vamos.peer; if (!shadow_ts) continue; + /* free lchan related mem allocated on the trx object: */ + for (ln = 0; ln < ARRAY_SIZE(shadow_ts->lchan); ln++) { + struct gsm_lchan *lchan = &shadow_ts->lchan[ln]; + TALLOC_FREE(lchan->name); + } + talloc_free(shadow_ts); trx->ts[tn].vamos.peer = NULL; } |