This is a note to let you know that I've just added the patch titled drivers: perf: Fix wrong put_cpu() placement to the 6.11-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: drivers-perf-fix-wrong-put_cpu-placement.patch and it can be found in the queue-6.11 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit f65d34dc605413f12ef026475132085372e29a7d Author: Alexandre Ghiti <alexghiti@xxxxxxxxxxxx> Date: Tue Nov 12 12:34:22 2024 +0100 drivers: perf: Fix wrong put_cpu() placement [ Upstream commit 57f7c7dc78cd09622b12920d92b40c1ce11b234e ] 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: 2840dadf0dde ("drivers: perf: Fix smp_processor_id() use in preemptible code") Reported-by: Atish Patra <atishp@xxxxxxxxxxxx> Link: https://lore.kernel.org/all/20240827125335.GD4772@willie-the-truck/ [1] Signed-off-by: Alexandre Ghiti <alexghiti@xxxxxxxxxxxx> Link: https://lore.kernel.org/r/20241112113422.617954-1-alexghiti@xxxxxxxxxxxx Signed-off-by: Palmer Dabbelt <palmer@xxxxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_sbi.c index 671dc55cbd3a8..bc562c759e1e9 100644 --- a/drivers/perf/riscv_pmu_sbi.c +++ b/drivers/perf/riscv_pmu_sbi.c @@ -1380,8 +1380,9 @@ static int pmu_sbi_device_probe(struct platform_device *pdev) goto out_unregister; cpu = get_cpu(); - ret = pmu_sbi_snapshot_setup(pmu, cpu); + put_cpu(); + if (ret) { /* Snapshot is an optional feature. Continue if not available */ pmu_sbi_snapshot_free(pmu); @@ -1395,7 +1396,6 @@ static int pmu_sbi_device_probe(struct platform_device *pdev) */ static_branch_enable(&sbi_pmu_snapshot_available); } - put_cpu(); } register_sysctl("kernel", sbi_pmu_sysctl_table);