perf tools: Set vmlinux_path__nr_entries to 0 in vmlinux_path__exit
authorWang Nan <[email protected]>
Sun, 17 May 2015 10:56:27 +0000 (10:56 +0000)
committerArnaldo Carvalho de Melo <[email protected]>
Mon, 18 May 2015 13:17:39 +0000 (10:17 -0300)
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.

Signed-off-by: Wang Nan <[email protected]>
Acked-by: Namhyung Kim <[email protected]>
Cc: Alexei Starovoitov <[email protected]
Cc: Brendan Gregg <[email protected]>
Cc: Daniel Borkmann <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: [email protected]
Cc: Zefan Li <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/perf/util/symbol.c

index 9ef8b8946b1125d673302596b56003433715c2c6..82a31fd0fcf5279dfd41c5db21a7c6962b39f398 100644 (file)
@@ -1819,6 +1819,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);
 }