diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2015-05-22 10:42:32 +0800 |
---|---|---|
committer | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2015-05-22 10:37:57 +0200 |
commit | d1cb41bfd020eb9b94b17e5bcaa5be36bceccc12 (patch) | |
tree | 71be0c17e837187ce9b8fa8a204f8004dc74cd67 /src/sysmo_l1_if.c | |
parent | 5752285bc55c00ddcba45c0168eef0cb0238a3a7 (diff) |
write_queue: Check the result of osmo_wqueue_enqueue and free
The write_queue is designed to have a maximum amount of pending
messages and will refuse to take new messages when it has been
reached. The caller can decide if it wants to flush the queue
and add the message again, create a log. But in all cases the
ownership of the msgb has not been transferred. Fix the potential
memory leak in the failure situation.
Diffstat (limited to 'src/sysmo_l1_if.c')
-rw-r--r-- | src/sysmo_l1_if.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/sysmo_l1_if.c b/src/sysmo_l1_if.c index bef680ef..c0721b87 100644 --- a/src/sysmo_l1_if.c +++ b/src/sysmo_l1_if.c @@ -36,7 +36,10 @@ static int l1if_req_pdch(struct femtol1_hdl *fl1h, struct msgb *msg) { struct osmo_wqueue *wqueue = &fl1h->write_q[MQ_PDTCH_WRITE]; - osmo_wqueue_enqueue(wqueue, msg); + if (osmo_wqueue_enqueue(wqueue, msg) != 0) { + LOGP(DL1IF, LOGL_ERROR, "PDTCH queue full. dropping message.\n"); + msgb_free(msg); + } return 0; } @@ -324,7 +327,10 @@ int l1if_pdch_req(void *obj, uint8_t ts, int is_ptcch, uint32_t fn, /* transmit */ - osmo_wqueue_enqueue(&fl1h->write_q[MQ_PDTCH_WRITE], msg); + if (osmo_wqueue_enqueue(&fl1h->write_q[MQ_PDTCH_WRITE], msg) != 0) { + LOGP(DL1IF, LOGL_ERROR, "PDTCH queue full. dropping message.\n"); + msgb_free(msg); + } return 0; } |