[PATCH] libosmocore[master]: rate_ctr: fix mem leak for mangled desc

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
Sat Nov 18 16:59:27 UTC 2017


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/4868

to look at the new patch set (#2).

rate_ctr: fix mem leak for mangled desc

Using the NULL context creates mem leaks that bother sanitizer builds.
Allocate as talloc "child" of the rate_ctr_group, so that the mangled desc (if
any) gets freed when the rate_ctr group is freed.

Remove the comment concerning osmo-msc: one way to fix if the talloc becomes
unexpected from this patch is to adjust the talloc expectations, another
(preferred) way is to have no invalid rate counter names in osmo-msc.

Change-Id: Ief9abfeb78b7706200bcc6aaa5dcb04fbeaa9b5b
---
M src/rate_ctr.c
1 file changed, 7 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/68/4868/2

diff --git a/src/rate_ctr.c b/src/rate_ctr.c
index 5464490..7b69127 100644
--- a/src/rate_ctr.c
+++ b/src/rate_ctr.c
@@ -190,15 +190,6 @@
 	unsigned int size;
 	struct rate_ctr_group *group;
 
-	/* attempt to mangle all '.' in identifiers to ':' for backwards compat */
-	if (!rate_ctrl_group_desc_validate(desc, true)) {
-		/* don't use 'ctx' here as it would screw up memory leak debugging e.g.
-		 * in osmo-msc */
-		desc = rate_ctr_group_desc_mangle(NULL, desc);
-		if (!desc)
-			return NULL;
-	}
-
 	size = sizeof(struct rate_ctr_group) +
 			desc->num_ctr * sizeof(struct rate_ctr);
 
@@ -209,6 +200,13 @@
 	if (!group)
 		return NULL;
 
+	/* attempt to mangle all '.' in identifiers to ':' for backwards compat */
+	if (!rate_ctrl_group_desc_validate(desc, true)) {
+		desc = rate_ctr_group_desc_mangle(group, desc);
+		if (!desc)
+			return NULL;
+	}
+
 	group->desc = desc;
 	group->idx = idx;
 

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ief9abfeb78b7706200bcc6aaa5dcb04fbeaa9b5b
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list