Re: [PATCH] arm_mpam: Free error_dev_id when destroying an MSC

From: Ben Horgan

Date: Thu Dec 03 2026 - 11:15:42 EST


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@xxxxxxxxx>
> ---
> 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@xxxxxxxxxxxxxxx/ instead of this patch
even though you did post first.

Thanks,

Ben

> platform_set_drvdata(pdev, NULL);
>
> add_to_garbage(msc);