From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D268C433B4 for ; Thu, 15 Apr 2021 14:20:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D83DF611F1 for ; Thu, 15 Apr 2021 14:20:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233270AbhDOOUu (ORCPT ); Thu, 15 Apr 2021 10:20:50 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:17344 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230056AbhDOOUt (ORCPT ); Thu, 15 Apr 2021 10:20:49 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4FLhJX1CFBzB1Hg; Thu, 15 Apr 2021 22:18:04 +0800 (CST) Received: from [127.0.0.1] (10.174.179.202) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.498.0; Thu, 15 Apr 2021 22:20:20 +0800 Subject: Re: [PATCH 1/1] perf map: Fix error return code in maps__clone() To: Arnaldo Carvalho de Melo , Jiri Olsa CC: Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , "Namhyung Kim" , linux-kernel References: <20210415092744.3793-1-thunder.leizhen@huawei.com> From: "Leizhen (ThunderTown)" Message-ID: <4bc1ad55-3ad9-be21-4ed1-5f0433ad8a61@huawei.com> Date: Thu, 15 Apr 2021 22:20:19 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.202] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> Signed-off-by: Zhen Lei >> --- >> 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 >> >> >