From: Gaurav Singh Date: Mon, 8 Jun 2020 16:18:17 +0000 (-0300) Subject: perf report: Fix NULL pointer dereference in hists__fprintf_nr_sample_events() X-Git-Tag: v4.14.186~35 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4e92c1239c13b29d248c9292955cb3526f0add42;p=users%2Fdwmw2%2Flinux.git perf report: Fix NULL pointer dereference in hists__fprintf_nr_sample_events() [ Upstream commit 11b6e5482e178055ec1f2444b55f2518713809d1 ] The 'evname' variable can be NULL, as it is checked a few lines back, check it before using. Fixes: 9e207ddfa207 ("perf report: Show call graph from reference events") Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Ingo Molnar Cc: Jiri Olsa Cc: Kan Liang Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/ Signed-off-by: Gaurav Singh Signed-off-by: Sasha Levin --- diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 429c3e140dc32..35a10b5985447 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -401,8 +401,7 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report if (evname != NULL) ret += fprintf(fp, " of event '%s'", evname); - if (symbol_conf.show_ref_callgraph && - strstr(evname, "call-graph=no")) { + if (symbol_conf.show_ref_callgraph && evname && strstr(evname, "call-graph=no")) { ret += fprintf(fp, ", show reference callgraph"); }