Skip to contentSkip to conversation

perf: Fix some hotplug callbask leaks

PATCH Applied Shang XiaoJing 2 participants 4 messages Nov 15, 2022 Arm PMU profiling and debugging

lore
Share & tools
lore
#0 lore raw

v2 cover perf: Fix some hotplug callbask leaks

There are some potential leaked hotplug callbacks that were found, and will be fixed by this patch.

Shang XiaoJing (2):
perf/arm_dmc620: Fix hotplug callback leak in dmc620_pmu_init() perf/smmuv3: Fix hotplug callback leak in arm_smmu_pmu_init()
---
changes in v2:
- use one instead of two separate returns.

---
 drivers/perf/arm_dmc620_pmu.c | 9 ++++++++-
 drivers/perf/arm_smmuv3_pmu.c | 9 ++++++++-
 2 files changed, 16 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
#1 lore raw

PATCH v2 1/2 perf/arm_dmc620: Fix hotplug callback leak in dmc620_pmu_init()

dmc620_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 53c218da220c ("driver/perf: Add PMU driver for the ARM DMC-620 memory controller")

---
changes in v2:
- use one instead of two separate returns.

---
 drivers/perf/arm_dmc620_pmu.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/perf/arm_dmc620_pmu.c +7 -1
index 280a6ae3e27c..54aa4658fb36 100644
@@ -725,6 +725,8 @@ static struct platform_driver dmc620_pmu_driver = {
 
 static int __init dmc620_pmu_init(void)
 {
+	int ret;
+
 	cpuhp_state_num = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN,
 				      DMC620_DRVNAME,
 				      NULL,
@@ -732,7 +734,11 @@ static int __init dmc620_pmu_init(void)
 	if (cpuhp_state_num < 0)
 		return cpuhp_state_num;
 
-	return platform_driver_register(&dmc620_pmu_driver);
+	ret = platform_driver_register(&dmc620_pmu_driver);
+	if (ret)
+		cpuhp_remove_multi_state(cpuhp_state_num);
+
+	return ret;
 }
 
 static void __exit dmc620_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
#2 lore raw

PATCH v2 2/2 perf/smmuv3: Fix hotplug callback leak in arm_smmu_pmu_init()

In reply to Shang XiaoJing

arm_smmu_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 7d839b4b9e00 ("perf/smmuv3: Add arm64 smmuv3 pmu driver")

---
changes in v2:
- use one instead of two separate returns.

---
 drivers/perf/arm_smmuv3_pmu.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/perf/arm_smmuv3_pmu.c +7 -1
index 00d4c45a8017..25a269d431e4 100644
@@ -959,6 +959,8 @@ static struct platform_driver smmu_pmu_driver = {
 
 static int __init arm_smmu_pmu_init(void)
 {
+	int ret;
+
 	cpuhp_state_num = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN,
 						  "perf/arm/pmcg:online",
 						  NULL,
@@ -966,7 +968,11 @@ static int __init arm_smmu_pmu_init(void)
 	if (cpuhp_state_num < 0)
 		return cpuhp_state_num;
 
-	return platform_driver_register(&smmu_pmu_driver);
+	ret = platform_driver_register(&smmu_pmu_driver);
+	if (ret)
+		cpuhp_remove_multi_state(cpuhp_state_num);
+
+	return ret;
 }
 module_init(arm_smmu_pmu_init);
 
Signature · 7 lines
2.17.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer Applied
#3 lore raw
In reply to Shang XiaoJing
Quoted 8 lines · Shang XiaoJing

There are some potential leaked hotplug callbacks that were found, and will be fixed by this patch.

Shang XiaoJing (2):
perf/arm_dmc620: Fix hotplug callback leak in dmc620_pmu_init() perf/smmuv3: Fix hotplug callback leak in arm_smmu_pmu_init()

[...]

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

[1/2] perf/arm_dmc620: Fix hotplug callback leak in dmc620_pmu_init()

      https://git.kernel.org/will/c/d9f564c966e6
[2/2] perf/smmuv3: Fix hotplug callback leak in arm_smmu_pmu_init()
      https://git.kernel.org/will/c/6f2d566b4643

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