perf record: Fix memory leak when using '--user-regs=?' to list registers
[ Upstream commit5.4-rM2-2.2.x-imx-squashed2eb5dd4180
] 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:bcc84ec65a
("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>
parent
ceadde18f6
commit
c16e42c932
|
@ -52,7 +52,7 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr)
|
||||||
}
|
}
|
||||||
fputc('\n', stderr);
|
fputc('\n', stderr);
|
||||||
/* just printing available regs */
|
/* just printing available regs */
|
||||||
return -1;
|
goto error;
|
||||||
}
|
}
|
||||||
for (r = sample_reg_masks; r->name; r++) {
|
for (r = sample_reg_masks; r->name; r++) {
|
||||||
if ((r->mask & mask) && !strcasecmp(s, r->name))
|
if ((r->mask & mask) && !strcasecmp(s, r->name))
|
||||||
|
|
Loading…
Reference in New Issue