Change in osmo-bts[master]: Make sure lchan allocated memory from shadow_ts is properly freed

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 09:38:54 UTC 2021


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/25741 )


Change subject: Make sure lchan allocated memory from shadow_ts is properly freed
......................................................................

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
---
M src/common/bts_trx.c
1 file changed, 7 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/41/25741/1

diff --git a/src/common/bts_trx.c b/src/common/bts_trx.c
index b16a31c..ff5c618 100644
--- a/src/common/bts_trx.c
+++ b/src/common/bts_trx.c
@@ -115,12 +115,19 @@
 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;
 	}

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/25741
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I73742535eb3c40a6866731acbff782940dab06c3
Gerrit-Change-Number: 25741
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/f7ac086e/attachment.htm>


More information about the gerrit-log mailing list