perf: qcom_l3_pmu: Remove CPU hotplug instances on probe failure
Subsystems (2)
PATCH 1/1 perf: qcom_l3_pmu: Remove CPU hotplug instances on probe failure
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.
--- drivers/perf/qcom_l3_pmu.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/perf/qcom_l3_pmu.c +12 -0
@@ -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
Signature · 1 line
2.43.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 11 lines
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 <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1