Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf probe: Fix an error handling path in 'parse_perf_probe_command()'

If a memory allocation fail, we should branch to the error handling path
in order to free some resources allocated a few lines above.

Fixes: 15354d54698648e2 ("perf probe: Generate event name with line number")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: kernel-janitors@vger.kernel.org
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/b71bcb01fa0c7b9778647235c3ab490f699ba278.1659797452.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Christophe JAILLET and committed by
Arnaldo Carvalho de Melo
4bf6dcaa 46f7bd5e

+4 -2
+4 -2
tools/perf/util/probe-event.c
··· 1775 1775 if (!pev->event && pev->point.function && pev->point.line 1776 1776 && !pev->point.lazy_line && !pev->point.offset) { 1777 1777 if (asprintf(&pev->event, "%s_L%d", pev->point.function, 1778 - pev->point.line) < 0) 1779 - return -ENOMEM; 1778 + pev->point.line) < 0) { 1779 + ret = -ENOMEM; 1780 + goto out; 1781 + } 1780 1782 } 1781 1783 1782 1784 /* Copy arguments and ensure return probe has no C argument */