Skip to content

Commit 76b8a0e

Browse files
mrutland-armwildea01
authored andcommitted
ARM: perf: handle armpmu_register failing
Currently perf_pmu_register may fail for several reasons (e.g. being unable to allocate memory for the struct device it associates with each PMU), and while any error is propagated by armpmu_register, it is ignored by cpu_pmu_device_probe and not propagated to the caller. This also results in a leak of a struct arm_pmu. This patch adds cleanup if armpmu_register fails, and updates the info messages to better differentiate this type of failure from a failure to probe the PMU type from the hardware or dt. Signed-off-by: Mark Rutland <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent 40c390c commit 76b8a0e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

arch/arm/kernel/perf_event_cpu.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,17 +277,22 @@ static int cpu_pmu_device_probe(struct platform_device *pdev)
277277
}
278278

279279
if (ret) {
280-
pr_info("failed to register PMU devices!");
281-
kfree(pmu);
282-
return ret;
280+
pr_info("failed to probe PMU!");
281+
goto out_free;
283282
}
284283

285284
cpu_pmu = pmu;
286285
cpu_pmu->plat_device = pdev;
287286
cpu_pmu_init(cpu_pmu);
288-
armpmu_register(cpu_pmu, PERF_TYPE_RAW);
287+
ret = armpmu_register(cpu_pmu, PERF_TYPE_RAW);
289288

290-
return 0;
289+
if (!ret)
290+
return 0;
291+
292+
out_free:
293+
pr_info("failed to register PMU devices!");
294+
kfree(pmu);
295+
return ret;
291296
}
292297

293298
static struct platform_driver cpu_pmu_driver = {

0 commit comments

Comments
 (0)