[PATCH v2] arm_mpam: Fix potential per-CPU memory leak on probe failure
From: Guangshuo Li
Date: Tue Nov 24 2026 - 08:58:56 EST
The PPI device IDs are allocated separately from the MSC. If subsequent
resource discovery fails, probe destroys the MSC without freeing its
per-CPU allocation.
Use devm_alloc_percpu() so the device releases the allocation when probe
fails. Its cleanup remains valid even if the MSC is freed beforehand.
This issue was found by our static analysis tool under development.
Fixes: 49aa621c4dca ("arm_mpam: Register and enable IRQs")
Cc: stable@xxxxxxxxxxxxxxx
Reviewed-by: Fenghua Yu <fenghuay@xxxxxxxxxx>
Signed-off-by: Guangshuo Li <liguangshuo@xxxxxxxxxxxxxxx>
---
Changes in v2:
- Use the arm_mpam subject prefix and describe a memory leak.
- Add Fenghua Yu's Reviewed-by. No code changes from v1.
drivers/resctrl/mpam_devices.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index 27abf60f4d67..ba341a6a59ce 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -2351,7 +2351,7 @@ static int __setup_ppi(struct mpam_msc *msc)
{
int cpu;
- msc->error_dev_id = alloc_percpu(struct mpam_msc *);
+ msc->error_dev_id = devm_alloc_percpu(&msc->pdev->dev, struct mpam_msc *);
if (!msc->error_dev_id)
return -ENOMEM;
base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
--
2.43.0