* [PATCH 1/1] perf map: Fix error return code in maps__clone()
@ 2021-04-15 9:27 Zhen Lei
2021-04-15 11:37 ` Jiri Olsa
2021-04-15 12:42 ` Arnaldo Carvalho de Melo
0 siblings, 2 replies; 4+ messages in thread
From: Zhen Lei @ 2021-04-15 9:27 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
linux-kernel
Cc: Zhen Lei
Although 'err' has been initialized to -ENOMEM, but it will be reassigned
by the "err = unwind__prepare_access(...)" statement in the for loop. So
that, the value of 'err' is unknown when map__clone() failed.
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
tools/perf/util/map.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index fbc40a2c17d4dca..8af693d9678cefe 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -840,15 +840,18 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
int maps__clone(struct thread *thread, struct maps *parent)
{
struct maps *maps = thread->maps;
- int err = -ENOMEM;
+ int err;
struct map *map;
down_read(&parent->lock);
maps__for_each_entry(parent, map) {
struct map *new = map__clone(map);
- if (new == NULL)
+
+ if (new == NULL) {
+ err = -ENOMEM;
goto out_unlock;
+ }
err = unwind__prepare_access(maps, new, NULL);
if (err)
--
2.26.0.106.g9fadedd
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] perf map: Fix error return code in maps__clone()
2021-04-15 9:27 [PATCH 1/1] perf map: Fix error return code in maps__clone() Zhen Lei
@ 2021-04-15 11:37 ` Jiri Olsa
2021-04-15 12:42 ` Arnaldo Carvalho de Melo
1 sibling, 0 replies; 4+ messages in thread
From: Jiri Olsa @ 2021-04-15 11:37 UTC (permalink / raw)
To: Zhen Lei
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Namhyung Kim, linux-kernel
On Thu, Apr 15, 2021 at 05:27:44PM +0800, Zhen Lei wrote:
> Although 'err' has been initialized to -ENOMEM, but it will be reassigned
> by the "err = unwind__prepare_access(...)" statement in the for loop. So
> that, the value of 'err' is unknown when map__clone() failed.
>
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
thanks,
jirka
> ---
> tools/perf/util/map.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
> index fbc40a2c17d4dca..8af693d9678cefe 100644
> --- a/tools/perf/util/map.c
> +++ b/tools/perf/util/map.c
> @@ -840,15 +840,18 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
> int maps__clone(struct thread *thread, struct maps *parent)
> {
> struct maps *maps = thread->maps;
> - int err = -ENOMEM;
> + int err;
> struct map *map;
>
> down_read(&parent->lock);
>
> maps__for_each_entry(parent, map) {
> struct map *new = map__clone(map);
> - if (new == NULL)
> +
> + if (new == NULL) {
> + err = -ENOMEM;
> goto out_unlock;
> + }
>
> err = unwind__prepare_access(maps, new, NULL);
> if (err)
> --
> 2.26.0.106.g9fadedd
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] perf map: Fix error return code in maps__clone()
2021-04-15 9:27 [PATCH 1/1] perf map: Fix error return code in maps__clone() Zhen Lei
2021-04-15 11:37 ` Jiri Olsa
@ 2021-04-15 12:42 ` Arnaldo Carvalho de Melo
2021-04-15 14:20 ` Leizhen (ThunderTown)
1 sibling, 1 reply; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-04-15 12:42 UTC (permalink / raw)
To: Zhen Lei, Jiri Olsa
Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
Jiri Olsa, Namhyung Kim, linux-kernel
Em Thu, Apr 15, 2021 at 05:27:44PM +0800, Zhen Lei escreveu:
> Although 'err' has been initialized to -ENOMEM, but it will be reassigned
> by the "err = unwind__prepare_access(...)" statement in the for loop. So
> that, the value of 'err' is unknown when map__clone() failed.
You forgot to research and add this:
Fixes: 6c502584438bda63 ("perf unwind: Call unwind__prepare_access for forked thread")
So that the stable@kernel.org guys can pick this up automagically and
apply this fix to the stable kernels.
I've added it.
Thanks, applied.
- Arnaldo
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> ---
> tools/perf/util/map.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
> index fbc40a2c17d4dca..8af693d9678cefe 100644
> --- a/tools/perf/util/map.c
> +++ b/tools/perf/util/map.c
> @@ -840,15 +840,18 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
> int maps__clone(struct thread *thread, struct maps *parent)
> {
> struct maps *maps = thread->maps;
> - int err = -ENOMEM;
> + int err;
> struct map *map;
>
> down_read(&parent->lock);
>
> maps__for_each_entry(parent, map) {
> struct map *new = map__clone(map);
> - if (new == NULL)
> +
> + if (new == NULL) {
> + err = -ENOMEM;
> goto out_unlock;
> + }
>
> err = unwind__prepare_access(maps, new, NULL);
> if (err)
> --
> 2.26.0.106.g9fadedd
>
>
--
- Arnaldo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] perf map: Fix error return code in maps__clone()
2021-04-15 12:42 ` Arnaldo Carvalho de Melo
@ 2021-04-15 14:20 ` Leizhen (ThunderTown)
0 siblings, 0 replies; 4+ messages in thread
From: Leizhen (ThunderTown) @ 2021-04-15 14:20 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Jiri Olsa
Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
Jiri Olsa, Namhyung Kim, linux-kernel
On 2021/4/15 20:42, Arnaldo Carvalho de Melo wrote:
> Em Thu, Apr 15, 2021 at 05:27:44PM +0800, Zhen Lei escreveu:
>> Although 'err' has been initialized to -ENOMEM, but it will be reassigned
>> by the "err = unwind__prepare_access(...)" statement in the for loop. So
>> that, the value of 'err' is unknown when map__clone() failed.
>
> You forgot to research and add this:
>
> Fixes: 6c502584438bda63 ("perf unwind: Call unwind__prepare_access for forked thread")
>
> So that the stable@kernel.org guys can pick this up automagically and
> apply this fix to the stable kernels.
>
> I've added it.
OK, thank you very much.
>
> Thanks, applied.
>
> - Arnaldo
>
>> Reported-by: Hulk Robot <hulkci@huawei.com>
>> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
>> ---
>> tools/perf/util/map.c | 7 +++++--
>> 1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
>> index fbc40a2c17d4dca..8af693d9678cefe 100644
>> --- a/tools/perf/util/map.c
>> +++ b/tools/perf/util/map.c
>> @@ -840,15 +840,18 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
>> int maps__clone(struct thread *thread, struct maps *parent)
>> {
>> struct maps *maps = thread->maps;
>> - int err = -ENOMEM;
>> + int err;
>> struct map *map;
>>
>> down_read(&parent->lock);
>>
>> maps__for_each_entry(parent, map) {
>> struct map *new = map__clone(map);
>> - if (new == NULL)
>> +
>> + if (new == NULL) {
>> + err = -ENOMEM;
>> goto out_unlock;
>> + }
>>
>> err = unwind__prepare_access(maps, new, NULL);
>> if (err)
>> --
>> 2.26.0.106.g9fadedd
>>
>>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-04-15 14:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-15 9:27 [PATCH 1/1] perf map: Fix error return code in maps__clone() Zhen Lei
2021-04-15 11:37 ` Jiri Olsa
2021-04-15 12:42 ` Arnaldo Carvalho de Melo
2021-04-15 14:20 ` Leizhen (ThunderTown)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).