From: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
To: Ji Sheng Teoh <jisheng.teoh@starfivetech.com>,
Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: [PATCH] perf: starfive: Fix potential per-CPU memory leak on probe failure
Date: Wed, 11 Nov 2026 20:23:16 +0800 [thread overview]
Message-ID: <20261111-e5624093d6-perf-starfive@mail.sdu.edu.cn> (raw)
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
reply other threads:[~2026-11-11 12:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261111-e5624093d6-perf-starfive@mail.sdu.edu.cn \
--to=liguangshuo@mail.sdu.edu.cn \
--cc=jisheng.teoh@starfivetech.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=stable@vger.kernel.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®