Skip to content

Commit

Permalink
perf config: Fix a memory leak in collect_config()
Browse files Browse the repository at this point in the history
[ Upstream commit 54569ba ]

Detected with gcc's ASan:

  Direct leak of 66 byte(s) in 5 object(s) allocated from:
      #0 0x7ff3b1f32070 in __interceptor_strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3b070)
      #1 0x560c8761034d in collect_config util/config.c:597
      #2 0x560c8760d9cb in get_value util/config.c:169
      #3 0x560c8760dfd7 in perf_parse_file util/config.c:285
      #4 0x560c8760e0d2 in perf_config_from_file util/config.c:476
      #5 0x560c876108fd in perf_config_set__init util/config.c:661
      torvalds#6 0x560c87610c72 in perf_config_set__new util/config.c:709
      torvalds#7 0x560c87610d2f in perf_config__init util/config.c:718
      torvalds#8 0x560c87610e5d in perf_config util/config.c:730
      torvalds#9 0x560c875ddea0 in main /home/changbin/work/linux/tools/perf/perf.c:442
      torvalds#10 0x7ff3afb8609a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)

Signed-off-by: Changbin Du <[email protected]>
Reviewed-by: Jiri Olsa <[email protected]>
Cc: Alexei Starovoitov <[email protected]>
Cc: Daniel Borkmann <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Steven Rostedt (VMware) <[email protected]>
Cc: Taeung Song <[email protected]>
Fixes: 20105ca ("perf config: Introduce perf_config_set class")
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
changbindu authored and gregkh committed Apr 20, 2019
1 parent 4f68dbc commit 6061a8c
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions tools/perf/util/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,11 +595,10 @@ static int collect_config(const char *var, const char *value,
}

ret = set_value(item, value);
return ret;

out_free:
free(key);
return -1;
return ret;
}

static int perf_config_set__init(struct perf_config_set *set)
Expand Down

0 comments on commit 6061a8c

Please sign in to comment.