From d1cb41bfd020eb9b94b17e5bcaa5be36bceccc12 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 22 May 2015 10:42:32 +0800 Subject: 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. --- src/openbts_sock.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/openbts_sock.cpp') diff --git a/src/openbts_sock.cpp b/src/openbts_sock.cpp index 2d9cae41..5e6f16c6 100644 --- a/src/openbts_sock.cpp +++ b/src/openbts_sock.cpp @@ -79,7 +79,10 @@ struct l1fwd_hdl *l1fh = talloc_zero(NULL, struct l1fwd_hdl); int pcu_sock_send(struct msgb *msg) { - osmo_wqueue_enqueue(&l1fh->udp_wq, msg); + if (osmo_wqueue_enqueue(&l1fh->udp_wq, msg) != 0) { + LOGP(DPCU, LOGL_ERROR, "PCU write queue full. Dropping message.\n"); + msgb_free(msg); + } return 0; } -- cgit v1.2.3