Re: [PATCH v1 03/11] perf top: Smatch: Fix potential NULL pointer dereference

Arnaldo Carvalho de Melo
2019-07-03T18:30:57Z

Em Tue, Jul 02, 2019 at 06:34:12PM +0800, Leo Yan escreveu:
> Based on the following report from Smatch, fix the potential
> NULL pointer dereference check.
>
> tools/perf/builtin-top.c:109
> perf_top__parse_source() warn: variable dereferenced before check 'he'
> (see line 103)
>
> tools/perf/builtin-top.c:233
> perf_top__show_details() warn: variable dereferenced before check 'he'
> (see line 228)
>
> tools/perf/builtin-top.c
> 101 static int perf_top__parse_source(struct perf_top *top, struct hist_entry *he)
> 102 {
> 103 struct perf_evsel *evsel = hists_to_evsel(he->hists);
> ^^^^
> 104 struct symbol *sym;
> 105 struct annotation *notes;
> 106 struct map *map;
> 107 int err = -1;
> 108
> 109 if (!he || !he->ms.sym)
> 110 return -1;
>
> This patch moves the values assignment after validating pointer 'he'.

Applied, thanks,

- Arnaldo