Change in libosmocore[master]: logging: Fix memory leak in case async log write queue overflows

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Thu Nov 25 12:41:59 UTC 2021


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/26360 )


Change subject: logging: Fix memory leak in case async log write queue overflows
......................................................................

logging: Fix memory leak in case async log write queue overflows

In case osmo_wqueue_enqueue_quiet() fails, msgb ownership is not
transferred to the queue, but the caller is responsible for freeing
the message buffer that we just failed to enqueue.

Change-Id: I6306e34dc7289864c889e72adf31d74d4581a810
Closes: OS#5328
Related: OS#5329
---
M src/logging.c
1 file changed, 4 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/60/26360/1

diff --git a/src/logging.c b/src/logging.c
index 9e2f5c2..b6c26d2 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -992,7 +992,10 @@
 	}
 	/* if we reach here, either we already had elements in the write_queue, or the synchronous write
 	 * failed: enqueue the message to the write_queue (backlog) */
-	osmo_wqueue_enqueue_quiet(target->tgt_file.wqueue, msg);
+	if (osmo_wqueue_enqueue_quiet(target->tgt_file.wqueue, msg) < 0) {
+		msgb_free(msg);
+		/* TODO: increment some counter so we can see that messages were dropped */
+	}
 }
 #endif
 

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/26360
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I6306e34dc7289864c889e72adf31d74d4581a810
Gerrit-Change-Number: 26360
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211125/776eef32/attachment.htm>


More information about the gerrit-log mailing list