* [PATCH] tools perf: set vmlinux_path__nr_entries to 0 in vmlinux_path__exit.
@ 2015-05-14 12:22 Wang Nan
2015-05-15 2:17 ` Namhyung Kim
0 siblings, 1 reply; 2+ messages in thread
From: Wang Nan @ 2015-05-14 12:22 UTC (permalink / raw)
To: paulus, a.p.zijlstra, mingo, acme, namhyung, jolsa,
adrian.hunter, dsahern
Cc: linux-kernel, lizefan, pi3orama, wangnan0
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 <wangnan0@huawei.com>
---
tools/perf/util/symbol.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 201f6c4c..451777f 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -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);
}
--
1.8.3.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] tools perf: set vmlinux_path__nr_entries to 0 in vmlinux_path__exit.
2015-05-14 12:22 [PATCH] tools perf: set vmlinux_path__nr_entries to 0 in vmlinux_path__exit Wang Nan
@ 2015-05-15 2:17 ` Namhyung Kim
0 siblings, 0 replies; 2+ messages in thread
From: Namhyung Kim @ 2015-05-15 2:17 UTC (permalink / raw)
To: Wang Nan
Cc: paulus, a.p.zijlstra, mingo, acme, jolsa, adrian.hunter, dsahern,
linux-kernel, lizefan, pi3orama
Hello,
On Thu, May 14, 2015 at 12:22:30PM +0000, Wang Nan wrote:
> 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 <wangnan0@huawei.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Thanks,
Namhyung
> ---
> tools/perf/util/symbol.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
> index 201f6c4c..451777f 100644
> --- a/tools/perf/util/symbol.c
> +++ b/tools/perf/util/symbol.c
> @@ -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);
> }
> --
> 1.8.3.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-05-15 2:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-14 12:22 [PATCH] tools perf: set vmlinux_path__nr_entries to 0 in vmlinux_path__exit Wang Nan
2015-05-15 2:17 ` Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®