sort : Fix null pointer dereference in _hist_entry__sym_snprintf
PATCH 1/1 sort : Fix null pointer dereference in _hist_entry__sym_snprintf
The pointer ms can be NULL. Add null check before
dereferencing it to avoid segmentation fault.
Signed-off-by Gaurav Singh <[email protected]>
--- tools/perf/util/sort.c | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/util/sort.c +3 -0
@@ -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 ;
Signature · 1 line
2.17.1
Quoted 5 lines
tools/perf/util/sort.c +0
-0
tools/perf/util/sort.c static int _hist_entry__sym_snprintf(struct map_symbol *ms, · line 302
Quoted 9 lines
tools/perf/util/sort.c +3
-0@@ -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