diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2018-03-09 15:33:59 +0700 |
---|---|---|
committer | Vadim Yanitskiy <axilirator@gmail.com> | 2018-03-11 14:18:22 +0700 |
commit | f06f31fdf7e0fc4fd2d4cb3a444855bfaafd59da (patch) | |
tree | 606cc6db4209385938bc9a451c24b558ef638d6d | |
parent | cbf818d4dcba53b226df8d36966482dc8b6d6ef4 (diff) |
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
-rw-r--r-- | src/host/trxcon/sched_trx.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/host/trxcon/sched_trx.c b/src/host/trxcon/sched_trx.c index 9ae5a8f6..1197f2ca 100644 --- a/src/host/trxcon/sched_trx.c +++ b/src/host/trxcon/sched_trx.c @@ -185,7 +185,7 @@ struct trx_ts *sched_trx_add_ts(struct trx_instance *trx, int tn) 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 @@ void sched_trx_del_ts(struct trx_instance *trx, int tn) 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); |