lkml.org 
[lkml]   [2020]   [Dec]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.4 301/453] perf record: Fix memory leak when using --user-regs=? to list registers
    Date
    From: Zheng Zengkai <zhengzengkai@huawei.com>

    [ Upstream commit 2eb5dd418034ecea2f7031e3d33f2991a878b148 ]

    When using 'perf record's option '-I' or '--user-regs=' along with
    argument '?' to list available register names, memory of variable 'os'
    allocated by strdup() needs to be released before __parse_regs()
    returns, otherwise memory leak will occur.

    Fixes: bcc84ec65ad1 ("perf record: Add ability to name registers to record")
    Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com>
    Acked-by: Jiri Olsa <jolsa@redhat.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Li Bin <huawei.libin@huawei.com>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Link: https://lore.kernel.org/r/20200703093344.189450-1-zhengzengkai@huawei.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    tools/perf/util/parse-regs-options.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    diff --git a/tools/perf/util/parse-regs-options.c b/tools/perf/util/parse-regs-options.c
    index ef46c28488085..869ef7e22bd91 100644
    --- a/tools/perf/util/parse-regs-options.c
    +++ b/tools/perf/util/parse-regs-options.c
    @@ -52,7 +52,7 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr)
    }
    fputc('\n', stderr);
    /* just printing available regs */
    - return -1;
    + goto error;
    }
    for (r = sample_reg_masks; r->name; r++) {
    if ((r->mask & mask) && !strcasecmp(s, r->name))
    --
    2.27.0


    \
     
     \ /
      Last update: 2020-12-28 16:37    [W:4.180 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site