All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] Fix null pointer dereference in hists__fprintf_nr_sample_events
       [not found] <CAFAFadADkyJ4qn8Ax2Ratnw03jHiTqY1pvj=AU6kwaqGDNkdfA@mail.gmail.com>
@ 2020-06-08 16:17 ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; only message in thread
From: Arnaldo Carvalho de Melo @ 2020-06-08 16:17 UTC (permalink / raw)
  To: gaurav singh
  Cc: peterz, mingo, mark.rutland, alexander.shishkin, jolsa, namhyung,
	linux-kernel

Em Sat, Jun 06, 2020 at 06:44:45PM -0400, gaurav singh escreveu:
> Hi,
> 
> evname is assigned if condition (evsel__is_group_event(evsel)) is true . It
> is checked for nullnuess here:
> 
>     if (evname != NULL) {
>         ret += fprintf(fp, " of event%s '%s'",
>                    evsel->core.nr_members > 1 ? "s" : "", evname);
>     }
> 
> and later on its used directly : strstr(evname, "call-graph=no")) which can
> possibly cause null pointer dereference. In order to fix this, add an an
> extra check in the if.
> 
> Please find the patch below.
> 
> Thanks and regards,
> Gaurav.

I'm applying the patch by hand, your e-mail client garbled it, I'm also
adding:

Cc: Kan Liang <kan.liang@intel.com>
Fixes: 9e207ddfa207 ("perf report: Show call graph from reference events")

Thanks,

- Arnaldo
 
> 
> From 399b3faaa5283a488f4227a13d69255e0f316d94 Mon Sep 17 00:00:00 2001
> From: Gaurav Singh <gaurav1086@gmail.com>
> Date: Sat, 6 Jun 2020 18:37:17 -0400
> Subject: [PATCH] Fix null pointer dereference in
>  hists__fprintf_nr_sample_events
> 
> Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
> ---
>  tools/perf/builtin-report.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
> index b63b3fb2de70..d8a45c28ba53 100644
> --- a/tools/perf/builtin-report.c
> +++ b/tools/perf/builtin-report.c
> @@ -478,7 +478,7 @@ static size_t hists__fprintf_nr_sample_events(struct
> hists *hists, struct report
>   if (rep->time_str)
>   ret += fprintf(fp, " (time slices: %s)", rep->time_str);
> 
> - if (symbol_conf.show_ref_callgraph &&
> + if (symbol_conf.show_ref_callgraph && evname != NULL &&
>      strstr(evname, "call-graph=no")) {
>   ret += fprintf(fp, ", show reference callgraph");
>   }
> -- 
> 2.17.1

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-06-08 16:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CAFAFadADkyJ4qn8Ax2Ratnw03jHiTqY1pvj=AU6kwaqGDNkdfA@mail.gmail.com>
2020-06-08 16:17 ` [PATCH] Fix null pointer dereference in hists__fprintf_nr_sample_events Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.