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

host/trxcon/scheduler: fix prim queue flushing function

For some reasons, the function, which is used to flush a queue of
transmit primitives, was intended to flush a list of msgb instances
instead of trx_ts_prim, so memory was being cleaned incorrectly.
Moreover, the items weren't actually removed from queue.

Change-Id: Ia84b57350a5c2eee0afebc65f62e30eaddb141d4
---
M src/host/trxcon/sched_trx.c
1 file changed, 8 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/79/6779/1

diff --git a/src/host/trxcon/sched_trx.c b/src/host/trxcon/sched_trx.c
index 7f6729c..c7520b9 100644
--- a/src/host/trxcon/sched_trx.c
+++ b/src/host/trxcon/sched_trx.c
@@ -37,12 +37,14 @@
 #include "trx_if.h"
 #include "logging.h"
 
-static void msgb_queue_flush(struct llist_head *list)
+static void prim_queue_flush(struct llist_head *list)
 {
-       struct msgb *msg, *msg2;
+       struct trx_ts_prim *prim, *prim_next;
 
-       llist_for_each_entry_safe(msg, msg2, list, list)
-               msgb_free(msg);
+       llist_for_each_entry_safe(prim, prim_next, list, list) {
+               llist_del(&prim->list);
+               talloc_free(prim);
+       }
 }
 
 static void sched_frame_clck_cb(struct trx_sched *sched)
@@ -191,7 +193,7 @@
        LOGP(DSCH, LOGL_NOTICE, "Delete TDMA timeslot #%u\n", tn);
 
        /* Flush queue primitives for TX */
-       msgb_queue_flush(&ts->tx_prims);
+       prim_queue_flush(&ts->tx_prims);
 
        /* Remove ts from list and free memory */
        trx->ts_list[tn] = NULL;
@@ -278,7 +280,7 @@
        ts->mf_layout = NULL;
 
        /* Flush queue primitives for TX */
-       msgb_queue_flush(&ts->tx_prims);
+       prim_queue_flush(&ts->tx_prims);
 
        /* Free channel states */
        talloc_free(ts->lchans);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia84b57350a5c2eee0afebc65f62e30eaddb141d4
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <lafo...@gnumonks.org>

Reply via email to