[PATCH] osmo-msc[master]: fix memory leak: vlr: vlr_gsupc_read_cb() must msgb_free()

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
Thu Sep 28 01:52:06 UTC 2017


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

fix memory leak: vlr: vlr_gsupc_read_cb() must msgb_free()

Add required msgb_free() to vlr_gsupc_read_cb().

Adjust msc_vlr_tests.c gsup_rx() to *not* free the msgb again after
vlr_gsupc_read_cb() did.

Related: OS#2476
Change-Id: I347c53f57a7fa79921aed3f6e42599841acf27c0
---
M src/libvlr/vlr.c
M tests/msc_vlr/msc_vlr_tests.c
2 files changed, 2 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/77/4077/1

diff --git a/src/libvlr/vlr.c b/src/libvlr/vlr.c
index 6094c9c..adfe258 100644
--- a/src/libvlr/vlr.c
+++ b/src/libvlr/vlr.c
@@ -804,6 +804,7 @@
 	       osmo_hexdump_nospc(msgb_l2(msg), msgb_l2len(msg)));
 
 	rc = osmo_gsup_decode(msgb_l2(msg), msgb_l2len(msg), &gsup);
+	msgb_free(msg);
 	if (rc < 0) {
 		LOGP(DVLR, LOGL_ERROR,
 			"decoding GSUP message fails with error '%s' (%d)\n",
diff --git a/tests/msc_vlr/msc_vlr_tests.c b/tests/msc_vlr/msc_vlr_tests.c
index a6e0f29..f9dc278 100644
--- a/tests/msc_vlr/msc_vlr_tests.c
+++ b/tests/msc_vlr/msc_vlr_tests.c
@@ -130,12 +130,12 @@
 	label = osmo_gsup_message_type_name(msg->l2h[0]);
 	fprintf(stderr, "<-- GSUP rx %s: %s\n", label,
 		osmo_hexdump_nospc(msgb_l2(msg), msgb_l2len(msg)));
+	/* GSUP read cb takes ownership of msgb */
 	rc = vlr_gsupc_read_cb(net->vlr->gsup_client, msg);
 	fprintf(stderr, "<-- GSUP rx %s: vlr_gsupc_read_cb() returns %d\n",
 		label, rc);
 	if (expect_tx_hex)
 		OSMO_ASSERT(gsup_tx_confirmed);
-	talloc_free(msg);
 }
 
 bool conn_exists(struct gsm_subscriber_connection *conn)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I347c53f57a7fa79921aed3f6e42599841acf27c0
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list