* [PATCH] arm_mpam: Free error_dev_id when destroying an MSC
@ 2026-10-27 11:19 Ping Li
2026-12-03 16:15 ` Ben Horgan
0 siblings, 1 reply; 3+ messages in thread
From: Ping Li @ 2026-10-27 11:19 UTC (permalink / raw)
To: james.morse, ben.horgan
Cc: linux-kernel, linux-arm-kernel, reinette.chatre, fenghuay, Ping Li
error_dev_id is allocated with alloc_percpu() when the MSC has a
per-CPU error interrupt, but is never freed. free_percpu_irq() only
releases the irqaction, not the percpu allocation. The msc structure
itself is devm managed, so the leak survives its devm_kfree().
free_percpu() accepts NULL, so MSCs without a PPI error interrupt
are unaffected.
Signed-off-by: Ping Li <leeonion.muyu@gmail.com>
---
drivers/resctrl/mpam_devices.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index 48adc49b833c..bff0b5da0fe6 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -2423,6 +2423,7 @@ static void mpam_msc_destroy(struct mpam_msc *msc)
list_del_rcu(&msc->all_msc_list);
synchronize_srcu(&mpam_srcu);
mpam_pcc_chan_put(msc->pcc_chan);
+ free_percpu(msc->error_dev_id);
platform_set_drvdata(pdev, NULL);
add_to_garbage(msc);
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] arm_mpam: Free error_dev_id when destroying an MSC
2026-10-27 11:19 [PATCH] arm_mpam: Free error_dev_id when destroying an MSC Ping Li
@ 2026-12-03 16:15 ` Ben Horgan
2026-12-04 3:28 ` Ping Li
0 siblings, 1 reply; 3+ messages in thread
From: Ben Horgan @ 2026-12-03 16:15 UTC (permalink / raw)
To: Ping Li, james.morse
Cc: linux-kernel, linux-arm-kernel, reinette.chatre, fenghuay
Hi Ping,
On 27/10/2026 11:19, Ping Li wrote:
> error_dev_id is allocated with alloc_percpu() when the MSC has a
> per-CPU error interrupt, but is never freed. free_percpu_irq() only
> releases the irqaction, not the percpu allocation. The msc structure
> itself is devm managed, so the leak survives its devm_kfree().
>
> free_percpu() accepts NULL, so MSCs without a PPI error interrupt
> are unaffected.
>
> Signed-off-by: Ping Li <leeonion.muyu@gmail.com>
> ---
> drivers/resctrl/mpam_devices.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
> index 48adc49b833c..bff0b5da0fe6 100644
> --- a/drivers/resctrl/mpam_devices.c
> +++ b/drivers/resctrl/mpam_devices.c
> @@ -2423,6 +2423,7 @@ static void mpam_msc_destroy(struct mpam_msc *msc)
> list_del_rcu(&msc->all_msc_list);
> synchronize_srcu(&mpam_srcu);
> mpam_pcc_chan_put(msc->pcc_chan);
> + free_percpu(msc->error_dev_id);
With this the msc->error_dev_id is still leaked if the probe fails. As such, I'm planning on taking
https://lore.kernel.org/linux-arm-kernel/20261124135843.2276437-1-liguangshuo@mail.sdu.edu.cn/ instead of this patch
even though you did post first.
Thanks,
Ben
> platform_set_drvdata(pdev, NULL);
>
> add_to_garbage(msc);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] arm_mpam: Free error_dev_id when destroying an MSC
2026-12-03 16:15 ` Ben Horgan
@ 2026-12-04 3:28 ` Ping Li
0 siblings, 0 replies; 3+ messages in thread
From: Ping Li @ 2026-12-04 3:28 UTC (permalink / raw)
To: ben.horgan, james.morse
Cc: Ping Li, liguangshuo, linux-kernel, linux-arm-kernel,
reinette.chatre, fenghuay
Hi Ben,
On 03/12/2026 16:15, Ben Horgan wrote:
> With this the msc->error_dev_id is still leaked if the probe fails. As such, I'm planning on taking
> https://lore.kernel.org/linux-arm-kernel/20261124135843.2276437-1-liguangshuo@mail.sdu.edu.cn/ instead of this patch
> even though you did post first.
Thanks for taking a look, and for the pointer to Guangshuo's patch.
You're right - mine only hooks mpam_msc_destroy(), so probe failures
after mpam_msc_setup_error_irq() still leak the allocation. I've read
the devm_alloc_percpu() version and am happy to withdraw mine in its
favour - devres cleanup covers both the probe-failure path and device
removal.
Glad the bug is being fixed either way.
Thanks,
Ping
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-04 3:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-27 11:19 [PATCH] arm_mpam: Free error_dev_id when destroying an MSC Ping Li
2026-12-03 16:15 ` Ben Horgan
2026-12-04 3:28 ` Ping 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®