Change in osmo-tetra[master]: fix memory leak in tetra_gsmtap_sendmsg()

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 13:50:17 UTC 2021


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-tetra/+/26363 )


Change subject: fix memory leak in tetra_gsmtap_sendmsg()
......................................................................

fix memory leak in tetra_gsmtap_sendmsg()

gsmtap_sendmsg() may return an error, and we need to free the msg.

Likewise, if we don't even call gsmtap_sendmsg, the msgb must be free'd.

Change-Id: I9b018165982996cafb2fd17e89646177462002c6
Related: OS#5329
---
M src/tetra_gsmtap.c
1 file changed, 8 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-tetra refs/changes/63/26363/1

diff --git a/src/tetra_gsmtap.c b/src/tetra_gsmtap.c
index 79b48a7..200ae3f 100644
--- a/src/tetra_gsmtap.c
+++ b/src/tetra_gsmtap.c
@@ -64,10 +64,15 @@
 
 int tetra_gsmtap_sendmsg(struct msgb *msg)
 {
-	if (g_gti)
-		return gsmtap_sendmsg(g_gti, msg);
-	else
+	if (g_gti) {
+		int rc = gsmtap_sendmsg(g_gti, msg);
+		if (rc < 0)
+			msgb_free(msg);
+		return rc;
+	} else {
+		msgb_free(msg);
 		return 0;
+	}
 }
 
 int tetra_gsmtap_init(const char *host, uint16_t port)

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

Gerrit-Project: osmo-tetra
Gerrit-Branch: master
Gerrit-Change-Id: I9b018165982996cafb2fd17e89646177462002c6
Gerrit-Change-Number: 26363
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/6bc7ca0b/attachment.htm>


More information about the gerrit-log mailing list