From patchwork Tue Oct 27 13:47:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 307150 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 6BB5FC4363A for ; Tue, 27 Oct 2020 17:23:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2053221D24 for ; Tue, 27 Oct 2020 17:23:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603819428; bh=huI7hy4Mxt2yRSeKlfuXeDbe3ZIKDWw1ulXgTzvE3rk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=XvP/gayb2Afsz3guY5ovFs1U9cSIaDZtVgyCQ0O2ksjthG9JFp9IAhLsmcYtelPhW fAvM1DA/cdt3yT1ASYCzaYjrKlvvGxk8XN5NR8F7LpZKqNaMN+x9dz2FB+0aWmm9gq ZyEbx3wvTGc+IGwqrvaLTiUooYclzr/WXa7a+XYk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751900AbgJ0Oyc (ORCPT ); Tue, 27 Oct 2020 10:54:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:50870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1773144AbgJ0Ove (ORCPT ); Tue, 27 Oct 2020 10:51:34 -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 4181722202; Tue, 27 Oct 2020 14:51:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810293; bh=huI7hy4Mxt2yRSeKlfuXeDbe3ZIKDWw1ulXgTzvE3rk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1xVYwT7LhOXVEjk8UspJIidlJw5J/+aUBwGJSLz0rMJR2eb791ACfB6s+Xddo+Uq7 Z6p8URv7vKqMIlJSbiO8z4wz7+3goLMMVMOS5ZiM7AfPudfosR77GFx4MgxuUxHYyg 3ppA/G6Zan2TA5TEW253GNn9bIEV3Eygp1j4Kea8= 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.8 089/633] drivers/perf: thunderx2_pmu: Fix memory resource error handling Date: Tue, 27 Oct 2020 14:47:12 +0100 Message-Id: <20201027135526.868515372@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@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);