[layer1] Fixed memory leak issue after releasing dedicated mode
authorAndreas.Eversberg <jolly@eversberg.eu>
Tue, 14 Sep 2010 19:13:36 +0000 (19:13 +0000)
committerAndreas.Eversberg <jolly@eversberg.eu>
Tue, 14 Sep 2010 19:13:36 +0000 (19:13 +0000)
While releasing dedicated mode, pending SDCCH and SACCH messages need to be
flushed. Without it, it would also cause old pending messages to be sent
during next dedicated mode.

src/target/firmware/include/layer1/async.h
src/target/firmware/layer1/async.c
src/target/firmware/layer1/l23_api.c

index 16b016e..ff23af5 100644 (file)
@@ -25,6 +25,9 @@ static inline void l1a_unlock_sync(void)
 /* safely enable a message into the L1S TX queue */
 void l1a_txq_msgb_enq(struct llist_head *queue, struct msgb *msg);
 
+/* flush all pending msgb */
+void l1a_txq_msgb_flush(struct llist_head *queue);
+
 /* request a RACH request at the next multiframe T3 = fn51 */
 void l1a_rach_req(uint8_t fn51, uint8_t mf_off, uint8_t ra);
 
index 68fee03..0b11ccc 100644 (file)
@@ -46,6 +46,18 @@ void l1a_txq_msgb_enq(struct llist_head *queue, struct msgb *msg)
        local_irq_restore(flags);
 }
 
+/* flush all pending msgb */
+void l1a_txq_msgb_flush(struct llist_head *queue)
+{
+       struct msgb *msg;
+       unsigned long flags;
+
+       local_firq_save(flags);
+       while ((msg = msgb_dequeue(queue)))
+               msgb_free(msg);
+       local_irq_restore(flags);
+}
+
 /* Enable a repeating multiframe task */
 void l1a_mftask_enable(enum mframe_task task)
 {
index 5080463..471e509 100644 (file)
@@ -253,6 +253,8 @@ static void l1ctl_rx_dm_rel_req(struct msgb *msg)
        printd("L1CTL_DM_REL_REQ\n");
        l1a_mftask_set(0);
        l1s.dedicated.type = GSM_DCHAN_NONE;
+       l1a_txq_msgb_flush(&l1s.tx_queue[L1S_CHAN_MAIN]);
+       l1a_txq_msgb_flush(&l1s.tx_queue[L1S_CHAN_SACCH]);
 }
 
 /* receive a L1CTL_RACH_REQ from L23 */