From patchwork Tue Oct 27 13:45:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 312551 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable 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 47B72C63697 for ; Tue, 27 Oct 2020 15:43:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 00D21223FB for ; Tue, 27 Oct 2020 15:43:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603813425; bh=huI7hy4Mxt2yRSeKlfuXeDbe3ZIKDWw1ulXgTzvE3rk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=vR9Tz9ZNgv2osKTSxL//IvkEvV62ZLmiLv3PUnRZazOGk8qvV1IyPAbkH5pzcF4uK kSTsNrkFh1LAKbm1R9bz9hpl19Proet4+Vdn0DJbBI9/4Yf9LJyMhuRp7RA3ud++9c SuwdB31VdYAssKo643+JdJM5e24qzkrki7NbWAKs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1797514AbgJ0P1v (ORCPT ); Tue, 27 Oct 2020 11:27:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:36888 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1797187AbgJ0PWH (ORCPT ); Tue, 27 Oct 2020 11:22:07 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E1F832224A; Tue, 27 Oct 2020 15:22:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603812126; bh=huI7hy4Mxt2yRSeKlfuXeDbe3ZIKDWw1ulXgTzvE3rk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tmRUkm8ltowMgzlC9Ve+NpQ7sYCqs+cZWGJJmXCApzvaKDJBREc/Y78iepxYDRoSG 2eA+VH7C8wmYGlbIYbh1KwWkOP12qNF+SE6lnY+63fCLufewxFKN6psaK91AZF0cTe x4xNgkrkMPozdstc80Z2uASQ7vJZYLvjGJ1gX5YU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Salter , Will Deacon , Sasha Levin Subject: [PATCH 5.9 101/757] drivers/perf: thunderx2_pmu: Fix memory resource error handling Date: Tue, 27 Oct 2020 14:45:51 +0100 Message-Id: <20201027135455.288474809@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135450.497324313@linuxfoundation.org> References: <20201027135450.497324313@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Mark Salter [ Upstream commit 688494a407d1419a6b158c644b262c61cde39f48 ] In tx2_uncore_pmu_init_dev(), a call to acpi_dev_get_resources() is used to create a list _CRS resources which is searched for the device base address. There is an error check following this: if (!rentry->res) return NULL In no case, will rentry->res be NULL, so the test is useless. Even if the test worked, it comes before the resource list memory is freed. None of this really matters as long as the ACPI table has the memory resource. Let's clean it up so that it makes sense and will give a meaningful error should firmware leave out the memory resource. Fixes: 69c32972d593 ("drivers/perf: Add Cavium ThunderX2 SoC UNCORE PMU driver") Signed-off-by: Mark Salter Link: https://lore.kernel.org/r/20200915204110.326138-2-msalter@redhat.com Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- drivers/perf/thunderx2_pmu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/perf/thunderx2_pmu.c b/drivers/perf/thunderx2_pmu.c index aac9823b0c6bb..e116815fa8092 100644 --- a/drivers/perf/thunderx2_pmu.c +++ b/drivers/perf/thunderx2_pmu.c @@ -805,14 +805,17 @@ static struct tx2_uncore_pmu *tx2_uncore_pmu_init_dev(struct device *dev, list_for_each_entry(rentry, &list, node) { if (resource_type(rentry->res) == IORESOURCE_MEM) { res = *rentry->res; + rentry = NULL; break; } } + acpi_dev_free_resource_list(&list); - if (!rentry->res) + if (rentry) { + dev_err(dev, "PMU type %d: Fail to find resource\n", type); return NULL; + } - acpi_dev_free_resource_list(&list); base = devm_ioremap_resource(dev, &res); if (IS_ERR(base)) { dev_err(dev, "PMU type %d: Fail to map resource\n", type);