perf probe: Avoid calling freeing routine multiple times for same pointer
authorArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 18 Jul 2019 14:28:37 +0000 (11:28 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 25 Aug 2019 08:51:29 +0000 (10:51 +0200)
commit217c52217e8af93288448c01f18cf09910df11f0
treeb635e05ce3a22b8c2ed72b1dc649a123ad8940ca
parent13810c478b5721bc100a1044bf7b9adddcd57aa6
perf probe: Avoid calling freeing routine multiple times for same pointer

[ Upstream commit d95daf5accf4a72005daa13fbb1d1bd8709f2861 ]

When perf_add_probe_events() we call cleanup_perf_probe_events() for the
pev pointer it receives, then, as part of handling this failure the main
'perf probe' goes on and calls cleanup_params() and that will again call
cleanup_perf_probe_events()for the same pointer, so just set nevents to
zero when handling the failure of perf_add_probe_events() to avoid the
double free.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-x8qgma4g813z96dvtw9w219q@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/perf/builtin-probe.c