diff options
| author | Mark Rutland <Mark.Rutland@arm.com> | 2013-01-18 08:42:58 -0500 |
|---|---|---|
| committer | Will Deacon <will.deacon@arm.com> | 2013-01-18 08:46:09 -0500 |
| commit | 76b8a0e4c8bda5f03574b8a904331266d162c796 (patch) | |
| tree | 1a525b2b01ed5e18a1d2a6f444b141b09c7d8292 | |
| parent | 40c390c768f898497e17d934f6715d516ff67294 (diff) | |
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 <mark.rutland@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
| -rw-r--r-- | arch/arm/kernel/perf_event_cpu.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c index 43496f600569..1f2740e3dbc0 100644 --- a/arch/arm/kernel/perf_event_cpu.c +++ b/arch/arm/kernel/perf_event_cpu.c | |||
| @@ -277,17 +277,22 @@ static int cpu_pmu_device_probe(struct platform_device *pdev) | |||
| 277 | } | 277 | } |
| 278 | 278 | ||
| 279 | if (ret) { | 279 | if (ret) { |
| 280 | pr_info("failed to register PMU devices!"); | 280 | pr_info("failed to probe PMU!"); |
| 281 | kfree(pmu); | 281 | goto out_free; |
| 282 | return ret; | ||
| 283 | } | 282 | } |
| 284 | 283 | ||
| 285 | cpu_pmu = pmu; | 284 | cpu_pmu = pmu; |
| 286 | cpu_pmu->plat_device = pdev; | 285 | cpu_pmu->plat_device = pdev; |
| 287 | cpu_pmu_init(cpu_pmu); | 286 | cpu_pmu_init(cpu_pmu); |
| 288 | armpmu_register(cpu_pmu, PERF_TYPE_RAW); | 287 | ret = armpmu_register(cpu_pmu, PERF_TYPE_RAW); |
| 289 | 288 | ||
| 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; | ||
| 291 | } | 296 | } |
| 292 | 297 | ||
| 293 | static struct platform_driver cpu_pmu_driver = { | 298 | static struct platform_driver cpu_pmu_driver = { |
