Skip to contentSkip to conversation

perf: Fix some hotplug callback leaks

PATCH Applied Yuan Can 3 participants 5 messages Nov 15, 2022 Arm PMU profiling and debugging

lore
Share & tools
lore

Yuan Can

author
#0 lore raw

cover perf: Fix some hotplug callback leaks

This series fix two error handling missing related problems that can lead to hotplug callback leaks.

Yuan Can (2):
perf: arm_dsu: Fix hotplug callback leak in dsu_pmu_init()
drivers: perf: marvell_cn10k: Fix hotplug callback leak in

    tad_pmu_init()
 drivers/perf/arm_dsu_pmu.c           | 6 +++++-
 drivers/perf/marvell_cn10k_tad_pmu.c | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)
Signature · 7 lines
2.17.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#1 lore raw

PATCH 1/2 perf: arm_dsu: Fix hotplug callback leak in dsu_pmu_init()

dsu_pmu_init() won't remove the callback added by cpuhp_setup_state_multi() when platform_driver_register() failed. Remove the callback by cpuhp_remove_multi_state() in fail path.

Similar to the handling of arm_ccn_init() in commit 26242b330093 ("bus:
arm-ccn: Prevent hotplug callback leak")

Fixes 7520fa99246d ("perf: ARM DynamIQ Shared Unit PMU support")
---
 drivers/perf/arm_dsu_pmu.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/perf/arm_dsu_pmu.c +5 -1
index 4a15c86f45ef..fe2abb412c00 100644
@@ -858,7 +858,11 @@ static int __init dsu_pmu_init(void)
 	if (ret < 0)
 		return ret;
 	dsu_pmu_cpuhp_state = ret;
-	return platform_driver_register(&dsu_pmu_driver);
+	ret = platform_driver_register(&dsu_pmu_driver);
+	if (ret)
+		cpuhp_remove_multi_state(dsu_pmu_cpuhp_state);
+
+	return ret;
 }
 
 static void __exit dsu_pmu_exit(void)
Signature · 7 lines
2.17.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] perf: arm_dsu: Fix hotplug callback leak in dsu_pmu_init()

Quoted 9 lines · Yuan Can

dsu_pmu_init() won't remove the callback added by cpuhp_setup_state_multi() when platform_driver_register() failed. Remove the callback by cpuhp_remove_multi_state() in fail path.

Similar to the handling of arm_ccn_init() in commit 26242b330093 ("bus:
arm-ccn: Prevent hotplug callback leak")

Fixes 7520fa99246d ("perf: ARM DynamIQ Shared Unit PMU support")
Quoted 11 lines
---
  drivers/perf/arm_dsu_pmu.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
drivers/perf/arm_dsu_pmu.c +0 -0
index 4a15c86f45ef..fe2abb412c00 100644
@@ -858,7 +858,11 @@ static int __init dsu_pmu_init(void)
  	if (ret < 0)
  		return ret;

drivers/perf/arm_dsu_pmu.c static int __init dsu_pmu_init(void) · line 868

Quoted 10 lines
drivers/perf/arm_dsu_pmu.c +5 -1
  	dsu_pmu_cpuhp_state = ret;
-	return platform_driver_register(&dsu_pmu_driver);
+	ret = platform_driver_register(&dsu_pmu_driver);
+	if (ret)
+		cpuhp_remove_multi_state(dsu_pmu_cpuhp_state);
+
+	return ret;
  }
 
  static void __exit dsu_pmu_exit(void)

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#3 lore raw

PATCH 2/2 drivers: perf: marvell_cn10k: Fix hotplug callback leak in tad_pmu_init()

In reply to Yuan Can

tad_pmu_init() won't remove the callback added by cpuhp_setup_state_multi() when platform_driver_register() failed. Remove the callback by cpuhp_remove_multi_state() in fail path.

Similar to the handling of arm_ccn_init() in commit 26242b330093 ("bus:
arm-ccn: Prevent hotplug callback leak")

Fixes 036a7584bede ("drivers: perf: Add LLC-TAD perf counter support")
---
 drivers/perf/marvell_cn10k_tad_pmu.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/perf/marvell_cn10k_tad_pmu.c +5 -1
index 69c3050a4348..a1166afb3702 100644
@@ -408,7 +408,11 @@ static int __init tad_pmu_init(void)
 	if (ret < 0)
 		return ret;
 	tad_pmu_cpuhp_state = ret;
-	return platform_driver_register(&tad_pmu_driver);
+	ret = platform_driver_register(&tad_pmu_driver);
+	if (ret)
+		cpuhp_remove_multi_state(tad_pmu_cpuhp_state);
+
+	return ret;
 }
 
 static void __exit tad_pmu_exit(void)
Signature · 7 lines
2.17.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer Applied
#4 lore raw
In reply to Yuan Can
Quoted 9 lines · Yuan Can

This series fix two error handling missing related problems that can lead to hotplug callback leaks.

Yuan Can (2):
perf: arm_dsu: Fix hotplug callback leak in dsu_pmu_init()
drivers: perf: marvell_cn10k: Fix hotplug callback leak in

    tad_pmu_init()

[...]

Applied to will (for-next/perf), thanks!

[1/2] perf: arm_dsu: Fix hotplug callback leak in dsu_pmu_init()

      https://git.kernel.org/will/c/facafab7611f
[2/2] drivers: perf: marvell_cn10k: Fix hotplug callback leak in tad_pmu_init()
      https://git.kernel.org/will/c/973ae93d80d9

Cheers,

Signature · 10 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel