perf: Fix NULL pointer ref in exclude_idle update
Commit 573979dee2
("perf: Add support for exclude_idle attribute")
registers an idle callback routine armv8pmu_idle_update. Currently
the idle update routine might be called before the pmu has allocated
all the per_cpu structures. This can result in a null pointer
reference. Change arm_pmu_device_probe to allocate the structures
via cpu_pmu_init() before the init_fn() call (which eventually does the
idle_notify_register call). Change a branch to out_free to
out_destroy as out_free doesn't cleanup what was allocated in
cpu_pmu_init(). Also have armv8pmu_idle_update check that the
structure is not null before using it.
Change-Id: Ie1198fc1783804c61467889c68656d6e8c9c9edf
Signed-off-by: Patrick Fay <pfay@codeaurora.org>
This commit is contained in:
parent
573979dee2
commit
377c09d738
2 changed files with 8 additions and 5 deletions
|
@ -590,6 +590,9 @@ static void armv8pmu_idle_update(struct arm_pmu *cpu_pmu)
|
|||
|
||||
hw_events = this_cpu_ptr(cpu_pmu->hw_events);
|
||||
|
||||
if (!hw_events)
|
||||
return;
|
||||
|
||||
for (idx = 0; idx < cpu_pmu->num_events; ++idx) {
|
||||
|
||||
if (!test_bit(idx, hw_events->used_mask))
|
||||
|
|
|
@ -1051,6 +1051,10 @@ int arm_pmu_device_probe(struct platform_device *pdev,
|
|||
|
||||
pmu->plat_device = pdev;
|
||||
|
||||
ret = cpu_pmu_init(pmu);
|
||||
if (ret)
|
||||
goto out_free;
|
||||
|
||||
if (node && (of_id = of_match_node(of_table, pdev->dev.of_node))) {
|
||||
init_fn = of_id->data;
|
||||
|
||||
|
@ -1073,13 +1077,9 @@ int arm_pmu_device_probe(struct platform_device *pdev,
|
|||
|
||||
if (ret) {
|
||||
pr_info("%s: failed to probe PMU!\n", of_node_full_name(node));
|
||||
goto out_free;
|
||||
goto out_destroy;
|
||||
}
|
||||
|
||||
ret = cpu_pmu_init(pmu);
|
||||
if (ret)
|
||||
goto out_free;
|
||||
|
||||
ret = perf_pmu_register(&pmu->pmu, pmu->name, -1);
|
||||
if (ret)
|
||||
goto out_destroy;
|
||||
|
|
Loading…
Add table
Reference in a new issue