aboutsummaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/net_dropmonitor.py
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <[email protected]>2023-06-06 16:11:10 -0300
committerArnaldo Carvalho de Melo <[email protected]>2023-06-12 15:57:37 -0300
commit36d3e4138e1b6cc9ab179f3f397b5548f8b1eaae (patch)
tree1403d6441e5e11ff64530d0d1bb5b475fe95f5bc /tools/perf/scripts/python/net_dropmonitor.py
parentd6748385098a8333a0e1c7e2d77119c919776728 (diff)
perf script: Fix allocation of evsel->priv related to per-event dump files
When printing output we may want to generate per event files, where the --per-event-dump option should be used, creating perf.data.EVENT.dump files instead of printing to stdout. The callback thar processes event thus expects that evsel->priv->fp should point to either the per-event FILE descriptor or to stdout. The a3af66f51bd0bca7 ("perf script: Fix crash because of missing evsel->priv") changeset fixed a case where evsel->priv wasn't setup, thus set to NULL, causing a segfault when trying to access evsel->priv->fp. But it did it for the non --per-event-dump case by allocating a 'struct perf_evsel_script' just to set its ->fp to stdout. Since evsel->priv is only freed when --per-event-dump is used, we ended up with a memory leak, detected using ASAN. Fix it by using the same method as perf_script__setup_per_event_dump(), and reuse that static 'struct perf_evsel_script'. Also check if evsel_script__new() failed. Fixes: a3af66f51bd0bca7 ("perf script: Fix crash because of missing evsel->priv") Reported-by: Ian Rogers <[email protected]> Tested-by: Ian Rogers <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Ravi Bangoria <[email protected]> Link: https://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Diffstat (limited to 'tools/perf/scripts/python/net_dropmonitor.py')
0 files changed, 0 insertions, 0 deletions