lkml.org 
[lkml]   [2020]   [Jun]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] [perf] sort : Fix null pointer dereference in _hist_entry__sym_snprintf
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index d42339df20f8..25c7c96893f6 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -294,6 +294,9 @@ static int _hist_entry__sym_snprintf(struct map_symbol *ms,
> u64 ip, char level, char *bf, size_t size,
> unsigned int width)
> {
> + if (!ms)
> + return 0;
> +
> struct symbol *sym = ms->sym;
> struct map *map = ms->map;
> size_t ret = 0;

This should have given warnings because Linux and perf coding style
forbids fixed statement/declarations.

Also what's the backtrace where it is NULL? Perhaps better to fix it in
the caller.

-Andi

\
 
 \ /
  Last update: 2020-06-18 16:15    [from the cache]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog