diff options
author | Harald Welte <laforge@osmocom.org> | 2021-11-25 13:38:19 +0100 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2021-11-25 13:38:19 +0100 |
commit | 9a9627ec36753f00d2b901781506fd563c235957 (patch) | |
tree | 61824bdf85a9bea337c61008771c4e7018673cc8 /src/logging.c | |
parent | 43b0cbe282f2f8d3772b2602384cfb76b6c9b880 (diff) |
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
Diffstat (limited to 'src/logging.c')
-rw-r--r-- | src/logging.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/logging.c b/src/logging.c index 9e2f5c26..b6c26d22 100644 --- a/src/logging.c +++ b/src/logging.c @@ -992,7 +992,10 @@ static void _file_raw_output(struct log_target *target, int subsys, unsigned int } /* 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 |