[PATCH] arm_pmu: acpi: handle allocation failure

Mark Rutland mark.rutland at arm.com
Tue Nov 8 01:37:25 PST 2022


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 <mark.rutland at arm.com>
Reported-by: Will Deacon <will at kernel.org>
---
 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;
-- 
2.30.2




More information about the linux-arm-kernel mailing list