mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] perf: starfive: Fix potential per-CPU memory leak on probe failure
@ 2026-11-11 12:23 Guangshuo Li
  0 siblings, 0 replies; only message in thread
From: Guangshuo Li @ 2026-11-11 12:23 UTC (permalink / raw)
  To: Ji Sheng Teoh, Will Deacon, Mark Rutland
  Cc: linux-arm-kernel, linux-perf-users, linux-kernel, stable

The per-CPU hardware events remain allocated when a later probe step
fails, although the device-managed PMU structure is released.

Allocate the events with devm_alloc_percpu() so failed probing releases
them after the interrupt handlers have been removed.

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

Fixes: c2b24812f7bc ("perf: starfive: Add StarLink PMU support")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
 drivers/perf/starfive_starlink_pmu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/perf/starfive_starlink_pmu.c b/drivers/perf/starfive_starlink_pmu.c
index d9843645554b..25d57b904028 100644
--- a/drivers/perf/starfive_starlink_pmu.c
+++ b/drivers/perf/starfive_starlink_pmu.c
@@ -519,8 +519,8 @@ static int starlink_pmu_probe(struct platform_device *pdev)
 	if (IS_ERR(starlink_pmu->pmu_base))
 		return PTR_ERR(starlink_pmu->pmu_base);
 
-	starlink_pmu->hw_events = alloc_percpu_gfp(struct starlink_hw_events,
-						   GFP_KERNEL);
+	starlink_pmu->hw_events = devm_alloc_percpu(&pdev->dev,
+						    struct starlink_hw_events);
 	if (!starlink_pmu->hw_events) {
 		dev_err(&pdev->dev, "Failed to allocate per-cpu PMU data\n");
 		return -ENOMEM;

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-11 12:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-11 12:23 [PATCH] perf: starfive: Fix potential per-CPU memory leak on probe failure Guangshuo Li

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

all inboxes | Powered by JetHome®