From patchwork Tue Nov 8 09:37:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 13036079 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 14365C433FE for ; Tue, 8 Nov 2022 09:38:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=RG8xqtPgPBGqP/MICZEJRconHqf6MmuswYv5i08yUYI=; b=QtlT4lgziamlKp FeR0Y3O/LoXTZf/u2fI9Qj/TGpKLkopYB3UJWlBkc8dq7KbQa7fUWSOvhskfrJ/RtvDciaTNty6eO h2FoA53b7NDvZJ7d9tAqln63xbt/YQgUdXwQ8aAaeBkezsgJeiTAEmDOGJEo5hSZ4oPF+YQz9pmzk ZaD87HVXcVMQZnZI/xeHOwJtJoljMC1xggN5/cMoSJbz5Ui8fQfzE21M/Ee00dvST6iZWuVfjRFM2 UML3NnbXVNcrc47VuLhyDIUifDJBNXmuqOHXBMmKD8+tK4mbmOXMb+dyHtmhet7MLTs1PmeOJUVn3 ZalXbIt6Xa7v8m3hpgpA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1osL35-0046yF-1J; Tue, 08 Nov 2022 09:37:39 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1osL31-0046xJ-Ll for linux-arm-kernel@lists.infradead.org; Tue, 08 Nov 2022 09:37:37 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 39A661FB; Tue, 8 Nov 2022 01:37:38 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 75CF33F534; Tue, 8 Nov 2022 01:37:31 -0800 (PST) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: mark.rutland@arm.com, will@kernel.org Subject: [PATCH] arm_pmu: acpi: handle allocation failure Date: Tue, 8 Nov 2022 09:37:25 +0000 Message-Id: <20221108093725.1239563-1-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221108_013735_776845_B2CA859A X-CRM114-Status: UNSURE ( 8.44 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org One of the failure paths in the arm_pmu ACPI code is missing an early return, permitting a NULL pointer dereference upon a memory allocation failure. Add the missing return. Fixes: fe40ffdb7656d1f9 ("arm_pmu: rework ACPI probing") Signed-off-by: Mark Rutland Reported-by: Will Deacon --- drivers/perf/arm_pmu_acpi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/perf/arm_pmu_acpi.c b/drivers/perf/arm_pmu_acpi.c index a085e45b509e1..90815ad762ebc 100644 --- a/drivers/perf/arm_pmu_acpi.c +++ b/drivers/perf/arm_pmu_acpi.c @@ -333,6 +333,7 @@ int arm_pmu_acpi_probe(armpmu_init_fn init_fn) if (!pmu) { pr_warn("Unable to allocate PMU for CPU%d\n", cpu); + return -ENOMEM; } cpuid = per_cpu(cpu_data, cpu).reg_midr;