Skip to contentSkip to conversation

tools perf: set vmlinux_path__nr_entries to 0 in vmlinux_path__exit.

PATCH Superseded Wang Nan 2 participants 2 messages May 14, 2015 – May 15, 2015 perf events

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Wang Nan

author
#0 lore raw

PATCH 1/1 tools perf: set vmlinux_path__nr_entries to 0 in vmlinux_path__exit.

Original vmlinux_path__exit() doesn't revert vmlinux_path__nr_entries to its original state. After the while loop vmlinux_path__nr_entries becomes -1 instead of 0. This makes a problem that, if runs twice, during the second run vmlinux_path__init() will set vmlinux_path[-1] to strdup("vmlinux"), corrupts random memory.

This patch reset vmlinux_path__nr_entries to 0 after the while loop.

---
 tools/perf/util/symbol.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/util/symbol.c +1 -0
index 201f6c4c..451777f 100644
@@ -1802,6 +1802,7 @@ static void vmlinux_path__exit(void)
 {
 	while (--vmlinux_path__nr_entries >= 0)
 		zfree(&vmlinux_path[vmlinux_path__nr_entries]);
+	vmlinux_path__nr_entries = 0;
 
 	zfree(&vmlinux_path);
 }
Signature · 1 line
1.8.3.4
maintainer Acked-by on v1 1/1
#1 lore raw

Hello,

Quoted 9 lines · Wang Nan

Original vmlinux_path__exit() doesn't revert vmlinux_path__nr_entries to its original state. After the while loop vmlinux_path__nr_entries becomes -1 instead of 0. This makes a problem that, if runs twice, during the second run vmlinux_path__init() will set vmlinux_path[-1] to strdup("vmlinux"), corrupts random memory.

This patch reset vmlinux_path__nr_entries to 0 after the while loop.

Thanks,
Namhyung

Quoted 24 lines
---
 tools/perf/util/symbol.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/util/symbol.c +1 -0
index 201f6c4c..451777f 100644
@@ -1802,6 +1802,7 @@ static void vmlinux_path__exit(void)
 {
 	while (--vmlinux_path__nr_entries >= 0)
 		zfree(&vmlinux_path[vmlinux_path__nr_entries]);
+	vmlinux_path__nr_entries = 0;
 
 	zfree(&vmlinux_path);
 }
Signature · 7 lines
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/