lkml.org 
[lkml]   [2015]   [May]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[RFC PATCH v3 02/37] perf tools: Set vmlinux_path__nr_entries to 0 in vmlinux_path__exit
    Date
    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>
    ---
    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


    \
     
     \ /
      Last update: 2015-05-17 13:21    [W:3.276 / U:0.016 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site