Linux Perf Users
 help / color / mirror / Atom feed
* [PATCH] perf: qcom_l3_pmu: Remove CPU hotplug instances on probe failure
@ 2026-11-26  8:29 Guangshuo Li
  2026-11-26  8:35 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Guangshuo Li @ 2026-11-26  8:29 UTC (permalink / raw)
  To: will, mark.rutland, agustinv
  Cc: linux-arm-msm, linux-arm-kernel, linux-perf-users

If perf PMU registration fails after CPU hotplug setup, the hotplug
callbacks retain a pointer to freed device data. A completed probe also
lacks a corresponding removal path.

Remove the hotplug instance on failure and detach it before
unregistering the PMU on removal.

This issue was found by our static analysis tool under development.

Fixes: 3071f13d75f6 ("perf: qcom: Add L3 cache PMU driver")
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
 drivers/perf/qcom_l3_pmu.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/perf/qcom_l3_pmu.c b/drivers/perf/qcom_l3_pmu.c
index 3e0c00e3733f..afb13882f0da 100644
--- a/drivers/perf/qcom_l3_pmu.c
+++ b/drivers/perf/qcom_l3_pmu.c
@@ -780,14 +780,25 @@ static int qcom_l3_cache_pmu_probe(struct platform_device *pdev)
 	ret = perf_pmu_register(&l3pmu->pmu, name, -1);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Failed to register L3 cache PMU (%d)\n", ret);
+		cpuhp_state_remove_instance_nocalls(CPUHP_AP_PERF_ARM_QCOM_L3_ONLINE,
+						    &l3pmu->node);
 		return ret;
 	}
 
+	platform_set_drvdata(pdev, l3pmu);
 	dev_info(&pdev->dev, "Registered %s, type: %d\n", name, l3pmu->pmu.type);
 
 	return 0;
 }
 
+static void qcom_l3_cache_pmu_remove(struct platform_device *pdev)
+{
+	struct l3cache_pmu *l3pmu = platform_get_drvdata(pdev);
+
+	cpuhp_state_remove_instance_nocalls(CPUHP_AP_PERF_ARM_QCOM_L3_ONLINE, &l3pmu->node);
+	perf_pmu_unregister(&l3pmu->pmu);
+}
+
 static const struct acpi_device_id qcom_l3_cache_pmu_acpi_match[] = {
 	{ "QCOM8081", },
 	{ }
@@ -801,6 +812,7 @@ static struct platform_driver qcom_l3_cache_pmu_driver = {
 		.suppress_bind_attrs = true,
 	},
 	.probe = qcom_l3_cache_pmu_probe,
+	.remove = qcom_l3_cache_pmu_remove,
 };
 
 static int __init register_qcom_l3_cache_pmu_driver(void)

base-commit: 4dce97c6c265544342e716e62fd24bbb232590c5
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] perf: qcom_l3_pmu: Remove CPU hotplug instances on probe failure
  2026-11-26  8:29 [PATCH] perf: qcom_l3_pmu: Remove CPU hotplug instances on probe failure Guangshuo Li
@ 2026-11-26  8:35 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-26  8:35 UTC (permalink / raw)
  To: Guangshuo Li; +Cc: linux-perf-users

> If perf PMU registration fails after CPU hotplug setup, the hotplug
> callbacks retain a pointer to freed device data. A completed probe also
> lacks a corresponding removal path.
> 
> Remove the hotplug instance on failure and detach it before
> unregistering the PMU on removal.
> 
> This issue was found by our static analysis tool under development.
> 
> Fixes: 3071f13d75f6 ("perf: qcom: Add L3 cache PMU driver")
> Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-a35bb25eb5-u21-0@mail.sdu.edu.cn?part=1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-26  8:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26  8:29 [PATCH] perf: qcom_l3_pmu: Remove CPU hotplug instances on probe failure Guangshuo Li
2026-11-26  8:35 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox