[PATCH] libosmo-netif[master]: osmo_stream_{cli, srv}_destroy: fix mem leak: empty msgb queue

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/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Fri Nov 17 02:33:36 UTC 2017


Review at  https://gerrit.osmocom.org/4878

osmo_stream_{cli,srv}_destroy: fix mem leak: empty msgb queue

On destroying a client or server stream, deallocate any msgbs that are still
pending in the queue.

In libosmo-sccp, the ss7_test.c in test_as(), messages are queued and were,
before this, left floating after the stream was destroyed, causing a sanitizer
memory leak. This patch fixes the leak.

Change-Id: Iaad35f03e3bdfabf3ba82b16e563c0a5d1f03639
---
M src/stream.c
1 file changed, 12 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/78/4878/1

diff --git a/src/stream.c b/src/stream.c
index 71c9b17..309fcd9 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -430,6 +430,12 @@
 {
 	osmo_stream_cli_close(cli);
 	osmo_timer_del(&cli->timer);
+	while (1) {
+		struct msgb *msg = msgb_dequeue(&cli->tx_queue);
+		if (!msg)
+			break;
+		talloc_free(msg);
+	}
 	talloc_free(cli);
 }
 
@@ -920,6 +926,12 @@
 	osmo_fd_unregister(&conn->ofd);
 	if (conn->closed_cb)
 		conn->closed_cb(conn);
+	while (1) {
+		struct msgb *msg = msgb_dequeue(&conn->tx_queue);
+		if (!msg)
+			break;
+		talloc_free(msg);
+	}
 	talloc_free(conn);
 }
 

-- 
To view, visit https://gerrit.osmocom.org/4878
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaad35f03e3bdfabf3ba82b16e563c0a5d1f03639
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list