lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Sat, 20 Jun 2020 14:46:20 +0800
From:   Wei Li <liwei391@...wei.com>
To:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        "Namhyung Kim" <namhyung@...nel.org>
CC:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>, <guohanjun@...wei.com>,
        <linux-kernel@...r.kernel.org>
Subject: [PATCH] perf list: Fix memleak in print_sdt_events()

Valgrind check info:
==30629== Command: ./perf list sdt
==30629==
==30629==
==30629== HEAP SUMMARY:
==30629==     in use at exit: 12,226 bytes in 195 blocks
==30629==   total heap usage: 3,239 allocs, 3,044 frees, 3,546,759 bytes allocated
==30629==
==30629== 8,028 bytes in 115 blocks are definitely lost in loss record 54 of 54
==30629==    at 0x4885E44: realloc (vg_replace_malloc.c:785)
==30629==    by 0x56468C3: __vasprintf_chk (in /usr/lib64/libc-2.28.so)
==30629==    by 0x5646723: __asprintf_chk (in /usr/lib64/libc-2.28.so)
==30629==    by 0x4E2C3F: asprintf (stdio2.h:181)
==30629==    by 0x4E2C3F: print_sdt_events (parse-events.c:2611)
==30629==    by 0x446587: cmd_list (builtin-list.c:87)
==30629==    by 0x4B8947: run_builtin (perf.c:312)
==30629==    by 0x4B8C13: handle_internal_command (perf.c:364)
==30629==    by 0x434717: run_argv (perf.c:408)
==30629==    by 0x434717: main (perf.c:538)
==30629==
==30629== LEAK SUMMARY:
==30629==    definitely lost: 8,028 bytes in 115 blocks
==30629==    indirectly lost: 0 bytes in 0 blocks
==30629==      possibly lost: 0 bytes in 0 blocks
==30629==    still reachable: 4,198 bytes in 80 blocks
==30629==         suppressed: 0 bytes in 0 blocks

Signed-off-by: Wei Li <liwei391@...wei.com>
---
 tools/perf/util/parse-events.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 3decbb203846..b2acacd5646e 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -2579,13 +2579,12 @@ void print_sdt_events(const char *subsys_glob, const char *event_glob,
 	struct probe_cache *pcache;
 	struct probe_cache_entry *ent;
 	struct strlist *bidlist, *sdtlist;
-	struct strlist_config cfg = {.dont_dupstr = true};
 	struct str_node *nd, *nd2;
 	char *buf, *path, *ptr = NULL;
 	bool show_detail = false;
 	int ret;
 
-	sdtlist = strlist__new(NULL, &cfg);
+	sdtlist = strlist__new(NULL, NULL);
 	if (!sdtlist) {
 		pr_debug("Failed to allocate new strlist for SDT\n");
 		return;
@@ -2610,8 +2609,10 @@ void print_sdt_events(const char *subsys_glob, const char *event_glob,
 				continue;
 			ret = asprintf(&buf, "%s:%s@%s", ent->pev.group,
 					ent->pev.event, nd->s);
-			if (ret > 0)
+			if (ret > 0) {
 				strlist__add(sdtlist, buf);
+				free(buf);
+			}
 		}
 		probe_cache__delete(pcache);
 	}
-- 
2.19.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ