check null of sym pointer before using it
From: Samuel Liao <[email protected]>
Sometimes, sym will be null that causing perf crash.
Signed-off-by Shan Wei <[email protected]>
--- tools/perf/ui/browsers/annotate.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
tools/perf/ui/browsers/annotate.c +3 -1
@@ -814,7 +814,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, {struct disasm_line *pos, *n;struct annotation *notes; -const size_t size =symbol__size (sym); +size_t size;struct map_symbol ms = { .map = map, .sym = sym,
@@ -834,6 +834,8 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,if (sym ==NULL )return -1 ; + size =symbol__size (sym); +if (map->dso->annotate_warned)return -1 ;
Signature · 1 line
1.7.1
ping.....
It's a obvious function bug.....
Shan Wei said, at 2012/6/5 13:14:
Quoted 31 lines
From: Samuel Liao <[email protected]>
Sometimes, sym will be null that causing perf crash.
Signed-off-by Shan Wei <[email protected]>--- tools/perf/ui/browsers/annotate.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)tools/perf/ui/browsers/annotate.c +3
-1@@ -814,7 +814,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, {struct disasm_line *pos, *n;struct annotation *notes; -const size_t size =symbol__size (sym); +size_t size;struct map_symbol ms = { .map = map, .sym = sym,@@ -834,6 +834,8 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,if (sym ==NULL )return -1 ; + size =symbol__size (sym); +if (map->dso->annotate_warned)return -1 ;
Hi,
Quoted 11 lines · Shan Wei
ping.....
It's a obvious function bug.....
Shan Wei said, at 2012/6/5 13:14:
Quoted 5 lines
From: Samuel Liao <[email protected]>
Sometimes, sym will be null that causing perf crash.
Signed-off-by Shan Wei <[email protected]>
Reviewed-by Namhyung Kim <[email protected]>
Thanks for the fix.
Namhyung
Quoted 26 lines
Quoted 26 lines
--- tools/perf/ui/browsers/annotate.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)tools/perf/ui/browsers/annotate.c +3
-1@@ -814,7 +814,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, {struct disasm_line *pos, *n;struct annotation *notes; -const size_t size =symbol__size (sym); +size_t size;struct map_symbol ms = { .map = map, .sym = sym,@@ -834,6 +834,8 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,if (sym ==NULL )return -1 ; + size =symbol__size (sym); +if (map->dso->annotate_warned)return -1 ;
[tip:perf/core] perf annotate: Check null of sym pointer before using it
In reply to Shan WeiCommit-ID: c0a58fb2bdf033df433cad9009c7dac4c6b872b0 Gitweb: http://git.kernel.org/tip/c0a58fb2bdf033df433cad9009c7dac4c6b872b0 Author: Samuel Liao <[email protected]> AuthorDate: Tue, 5 Jun 2012 13:14:59 +0800 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 19 Jun 2012 14:30:26 -0300
perf annotate: Check null of sym pointer before using it
Sym may be NULL, and that will cause perf to crash.
Signed-off-by Shan Wei <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/ui/browsers/annotate.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
tools/perf/ui/browsers/annotate.c +3 -1
@@ -814,7 +814,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, {struct disasm_line *pos, *n;struct annotation *notes; -const size_t size =symbol__size (sym); +size_t size;struct map_symbol ms = { .map = map, .sym = sym,
@@ -834,6 +834,8 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,if (sym ==NULL )return -1 ; + size =symbol__size (sym); +if (map->dso->annotate_warned)return -1 ;