]> git.baikalelectronics.ru Git - kernel.git/commit
perf probe: Set pev->nargs to zero after freeing pev->args entries
authorArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 18 Jul 2019 14:22:58 +0000 (11:22 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 23 Jul 2019 12:04:25 +0000 (09:04 -0300)
commitfef699f2d57bdf309830ab097ac9909f19116256
treecc92a4b5897811bc26881b937f6947500ba248ba
parent78ca8017cb9ea7248c92604deadcea8c90773947
perf probe: Set pev->nargs to zero after freeing pev->args entries

So that, when perf_add_probe_events() fails, like in:

  # perf probe icmp_rcv:64 "type=icmph->type"
  Failed to find 'icmph' in this function.
    Error: Failed to add events.
  Segmentation fault (core dumped)
  #

We don't segfault.

clear_perf_probe_event() was zeroing the whole pev, and since the switch
to zfree() for the members in the pev, that memset() was removed, which
left nargs with its original value, in the above case 1.

With the memset the same pev could be passed to clear_perf_probe_event()
multiple times, since all it would have would be zeroes, and free()
accepts zero, the loop would not happen and we would just memset it
again to zeroes.

Without it we got that segfault, so zero nargs to keep it like it was,
next cset will avoid calling clear_perf_probe_event() for the same pevs
in case of failure.

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>
Fixes: 6dbc6df7b017 ("perf tools: Use zfree() where applicable")
Link: https://lkml.kernel.org/n/tip-802f2jypnwqsvyavvivs8464@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/probe-event.c