Skip to content

Commit b78854e

Browse files
committed
perf probe: Use zfree() to avoid possibly accessing dangling pointers
When freeing a->b it is good practice to set a->b to NULL using zfree(&a->b) so that when we have a bug where a reference to a freed 'a' pointer is kept somewhere, we can more quickly cause a segfault if some code tries to use a->b. Convert one such case in the 'perf probe' codebase. Cc: Adrian Hunter <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Namhyung Kim <[email protected]> Link: https://lore.kernel.org/lkml/ZjpBnkL2wO3QJa5W@x1 Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent ee73fe9 commit b78854e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/perf/builtin-probe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ static void cleanup_params(void)
325325
for (i = 0; i < params->nevents; i++)
326326
clear_perf_probe_event(params->events + i);
327327
line_range__clear(&params->line_range);
328-
free(params->target);
328+
zfree(&params->target);
329329
strfilter__delete(params->filter);
330330
nsinfo__put(params->nsi);
331331
zfree(&params);

0 commit comments

Comments
 (0)