From patchwork Mon Apr 26 07:30:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 427530 Delivered-To: patch@linaro.org Received: by 2002:a17:906:6d12:0:0:0:0 with SMTP id m18csp3588411ejr; Mon, 26 Apr 2021 00:45:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZyQohXwb4jclZ2fFB6PcnPdwyXE6vXedZrnIjRBMalTaK070XZabi07RHejJbKF8vxCAy X-Received: by 2002:a17:902:fe0b:b029:ed:4006:6dac with SMTP id g11-20020a170902fe0bb02900ed40066dacmr750267plj.20.1619423119410; Mon, 26 Apr 2021 00:45:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619423119; cv=none; d=google.com; s=arc-20160816; b=ock7YYWedMSupEy4uivIwuOPTlopK3kpfmcok5wrP9WvqnyscRoxuHAtN89jAcHaIk GWVtyIaKtde0sxSUqmIn6450DuDMYwTBCdmeWh1LkszGu2dA4xheHZdR+FSIMTFPhR2q fOLObEAIX35/+0TO7n+k6Dx058nkT70iBHhhodU3rQC/pBnPh2cTGAlgLV//B85kVoDV AkM5jLo3OMFhA5hSesM80zzYJIC4dooJaJ3GXbHYdBrrhbyEZsVzxH1ysiVkMPzQD666 5AlhWRR51tFfmkL2RCi43Oail/hCRpo9vlokcWphWOklUPJf/D4Y6hL4DRIxj+kBEpIl zK7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AZYdwgZoJ8ayyCQFkm+ddX8m9kZmeMZ08ZxEms51PLE=; b=Il7yZh6QtZIDQt4XcQhCSv8Pf7rwyQ1eW+8/SYU0YsgeV4pvTjKDU2eBrq134C+XSH HUktwuPzCzvFfdE7uUgDJHDI+CKe0Zt+gUFCMM+p8QXGhXciMYVlqPlM8YgWcY1U73QA yPIMf147l2XwohuJXWZu9xUi5MwrYVxLHCS2bqvFHaC/ZKUhiWDLrOBm0tcHWtJ7L+rQ EUXuy6SO2JDIev8G/5IT7OyGk7p2gYBV4k1QakJn8HKEzZfHyIsU5cfqcXj47KNQsngD KwQn55H+q8UgX0Kv4pJEleaMTuwqHn8QDaue9yNiL7MNEon0ThpOkAHTualH16scjOmo eKvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yR71Rw8g; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i7si16086476pgs.487.2021.04.26.00.45.19; Mon, 26 Apr 2021 00:45:19 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yR71Rw8g; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233279AbhDZHpw (ORCPT + 12 others); Mon, 26 Apr 2021 03:45:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:37316 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233988AbhDZHoj (ORCPT ); Mon, 26 Apr 2021 03:44:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8BB07613F1; Mon, 26 Apr 2021 07:41:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1619422864; bh=KVuSzgEWL8yOaClH1gfHCtSceNgJivoQJwjpO7bOolE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yR71Rw8gZJQhuy53QSrxLI/mw89J3Lk0ASPhtZdJs5OSxXvUMID5UPqY9vKF2lLUD YN/mNnbzBF5js2T0soeLV5n0v3ehmijQ+IkIJJUZiAPFtD2S6KrvW45Unz+oLY4NAD Ee6v43/xm9rq6qOcLVneaoY9RCbk6OF3/+9Z5An8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Zhen Lei , Alexander Shishkin , Jiri Olsa , Mark Rutland , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.11 21/41] perf map: Fix error return code in maps__clone() Date: Mon, 26 Apr 2021 09:30:08 +0200 Message-Id: <20210426072820.404080371@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210426072819.666570770@linuxfoundation.org> References: <20210426072819.666570770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Zhen Lei [ Upstream commit c6f87141254d16e281e4b4431af7316895207b8f ] 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. Fixes: 6c502584438bda63 ("perf unwind: Call unwind__prepare_access for forked thread") Reported-by: Hulk Robot Signed-off-by: Zhen Lei Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: zhen lei Link: http://lore.kernel.org/lkml/20210415092744.3793-1-thunder.leizhen@huawei.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/map.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- 2.30.2 diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index e2537d5acab0..f4d44f75ba15 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -836,15 +836,18 @@ out: 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)