Skip to content

Commit 57f7c7d

Browse files
Alexandre Ghitipalmer-dabbelt
authored andcommitted
drivers: perf: Fix wrong put_cpu() placement
Unfortunately, the wrong patch version was merged which places the put_cpu() after enabling a static key, which is not safe as pointed by Will [1], so move put_cpu() before to avoid this. Fixes: 2840dad ("drivers: perf: Fix smp_processor_id() use in preemptible code") Reported-by: Atish Patra <[email protected]> Link: https://lore.kernel.org/all/20240827125335.GD4772@willie-the-truck/ [1] Signed-off-by: Alexandre Ghiti <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 59b723c commit 57f7c7d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/perf/riscv_pmu_sbi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,8 +1393,9 @@ static int pmu_sbi_device_probe(struct platform_device *pdev)
13931393
goto out_unregister;
13941394

13951395
cpu = get_cpu();
1396-
13971396
ret = pmu_sbi_snapshot_setup(pmu, cpu);
1397+
put_cpu();
1398+
13981399
if (ret) {
13991400
/* Snapshot is an optional feature. Continue if not available */
14001401
pmu_sbi_snapshot_free(pmu);
@@ -1408,7 +1409,6 @@ static int pmu_sbi_device_probe(struct platform_device *pdev)
14081409
*/
14091410
static_branch_enable(&sbi_pmu_snapshot_available);
14101411
}
1411-
put_cpu();
14121412
}
14131413

14141414
register_sysctl("kernel", sbi_pmu_sysctl_table);

0 commit comments

Comments
 (0)