Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp321034pxx; Wed, 28 Oct 2020 05:53:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQCgqnwGiiydY5zmMgrfITLTtImyygaqjBLiaIWqhbFzuPHSRWrn3MAcYF/n3gRCrLDyAz X-Received: by 2002:a05:6402:17ac:: with SMTP id j12mr4065310edy.31.1603889590272; Wed, 28 Oct 2020 05:53:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603889590; cv=none; d=google.com; s=arc-20160816; b=CSQ7jd1HIEgSzDN6bTQEjKxqVxy9W60KK18Di8nptbXBSTYW5QVRkSZ54fkr581Bg8 Y+8530Jh740kVKoQdj1JGNlHJ5zmFk/7s74sb7hwX2d8YwOAUP66a63Zfyhn1j8qA4e/ VT+tk3HunYLpK/Qxip7oZWbm9yOdam4MgM6OnXarAhzSrUKAudYZeg4RrF5I135D3McA zZeZL/m14dx7TxucN2ommxK6YyYz8x2nqGOTE5zHzzcMcC3GJp4/GAFs1Nw/SZ510kjC 3f41WPFtzcYPf7yZBG0EVx4zJn9gjIqUER0ZBBPdW2rOprrO0sRKTID1nCEDzCpc+gSw Iq2Q== 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=bb2uen47pDWo6+ZYfP0dcMkwnysoT0g3tyHMuqSVNc4=; b=mgKyJav7i7nXRMn378Kx53MV/pL+uNlTTG5fheKfO6zO8ot0yTn782iLOVAipf4JUc lbCbjOp6jyFNM77ungBxXXx70KJkoVt9dCVM/8264raT3P8Np5RdkroEAz5bDE9ICdg5 uHyGT6wWDeW/e8sJFPXIMBvLcJdkqj4TaGorCGiOuH1MVw/RJf4OgHietXcYbaQTuDSe yFlrzpxijURhcowsYYq6Paf0eoyMipwALmc7B2r1Df33/osVMVtCVL5mtK1DNKcFVMrw Jvsqj2xUrG9o1RDCKcCtsTowTkyzxCBR7thq8+wCNDl4+P9HJ5Bo8XrA90cxapw86buw /6Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tmRUkm8l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (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 s16si2897729edy.300.2020.10.28.05.52.48; Wed, 28 Oct 2020 05:53:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@kernel.org header.s=default header.b=tmRUkm8l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1799400AbgJ0PbR (ORCPT + 99 others); Tue, 27 Oct 2020 11:31:17 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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); -- 2.25.1