2012-06-05 05:13:56

by Shan Wei

[permalink] [raw]
Subject: [Perf bug-fix] 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(-)

diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 4deea6a..50873a8 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -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;

--
1.7.1


2012-06-11 02:06:03

by Shan Wei

[permalink] [raw]
Subject: Re: [Perf bug-fix] check null of sym pointer before using it


ping.....

It's a obvious function bug.....

Shan Wei said, at 2012/6/5 13:14:

> 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(-)
>
> diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
> index 4deea6a..50873a8 100644
> --- a/tools/perf/ui/browsers/annotate.c
> +++ b/tools/perf/ui/browsers/annotate.c
> @@ -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;
>

2012-06-11 04:48:24

by Namhyung Kim

[permalink] [raw]
Subject: Re: [Perf bug-fix] check null of sym pointer before using it

Hi,

On Mon, 11 Jun 2012 10:07:10 +0800, Shan Wei wrote:
> ping.....
>
> It's a obvious function bug.....
>
> Shan Wei said, at 2012/6/5 13:14:
>
>> 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


>> ---
>> tools/perf/ui/browsers/annotate.c | 4 +++-
>> 1 files changed, 3 insertions(+), 1 deletions(-)
>>
>> diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
>> index 4deea6a..50873a8 100644
>> --- a/tools/perf/ui/browsers/annotate.c
>> +++ b/tools/perf/ui/browsers/annotate.c
>> @@ -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;
>>

2012-06-20 17:03:17

by samuelliao(廖生苗)

[permalink] [raw]
Subject: [tip:perf/core] perf annotate: Check null of sym pointer before using it

Commit-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]>
Link: http://lkml.kernel.org/r/[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(-)

diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 34b1c46..67a2703 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -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;