[PATCH] osmocom-bb[fixeria/trx]: trxcon/sched_trx.c: fix: properly deallocate lchans

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/.

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Sun Mar 11 07:55:43 UTC 2018


Review at  https://gerrit.osmocom.org/7202

trxcon/sched_trx.c: fix: properly deallocate lchans

The llist_for_each_entry_safe() should be used instead of the
llist_for_each_entry(), because it's safe against removal
of llist entry.

Found using Valgrind's memcheck tool.

Change-Id: I65234971ec152df038c5388da537a503060c215b
---
M src/host/trxcon/sched_trx.c
1 file changed, 4 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/02/7202/1

diff --git a/src/host/trxcon/sched_trx.c b/src/host/trxcon/sched_trx.c
index 9ae5a8f..1197f2c 100644
--- a/src/host/trxcon/sched_trx.c
+++ b/src/host/trxcon/sched_trx.c
@@ -185,7 +185,7 @@
 
 void sched_trx_del_ts(struct trx_instance *trx, int tn)
 {
-	struct trx_lchan_state *lchan;
+	struct trx_lchan_state *lchan, *lchan_next;
 	struct trx_ts *ts;
 
 	/* Find ts in list */
@@ -199,8 +199,10 @@
 	sched_trx_deactivate_all_lchans(ts);
 
 	/* Free channel states */
-	llist_for_each_entry(lchan, &ts->lchans, list)
+	llist_for_each_entry_safe(lchan, lchan_next, &ts->lchans, list) {
+		llist_del(&lchan->list);
 		talloc_free(lchan);
+	}
 
 	/* Flush queue primitives for TX */
 	sched_prim_flush_queue(&ts->tx_prims);

-- 
To view, visit https://gerrit.osmocom.org/7202
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I65234971ec152df038c5388da537a503060c215b
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>



More information about the gerrit-log mailing list