Re: [PATCH 2/4] fs/resctrl: Free mon_data structures on rdt_get_tree() failure
From: Luck, Tony
Date: Fri May 08 2026 - 17:37:32 EST
On Fri, May 08, 2026 at 11:21:41AM -0700, Tony Luck wrote:
> If mkdir_mondata_all() succeeds but a subsequent call in rdt_get_tree()
> fails, the mon_data structures allocated by mon_get_kn_priv() are
> leaked. Add mon_put_kn_priv() to the out_mondata error path to free
> them.
>
> mon_get_kn_priv() and mon_put_kn_priv() moved so defined before used.
My bad, leaving this stale commit comment here. Code rearrangement
in patch 1 covered this.
> Fixes: ee4f0ec938ad ("fs/resctrl: Simplify allocation of mon_data structures")
> Reported-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
> Assisted-by: GitHub_Copilot_CLI:claude-sonnet-4.6
Hmmm. I don't think I was assisted at all. Actively sabotaged with a
patch that looks plausible, but it actually wrong seems more accurate.
> Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>
> ---
> fs/resctrl/rdtgroup.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
> index a6376a3fc4c3..0db1a92aefbe 100644
> --- a/fs/resctrl/rdtgroup.c
> +++ b/fs/resctrl/rdtgroup.c
> @@ -3067,8 +3067,10 @@ static int rdt_get_tree(struct fs_context *fc)
> out_psl:
> rdt_pseudo_lock_release();
> out_mondata:
> - if (resctrl_arch_mon_capable())
> + if (resctrl_arch_mon_capable()) {
> + mon_put_kn_priv();
Claude put this call here ...
> kernfs_remove(kn_mondata);
> + }
> out_mongrp:
> if (resctrl_arch_mon_capable()) {
But it really ought to be here.
> rdtgroup_unassign_cntrs(&rdtgroup_default);
> --
> 2.54.0
Claude is fired. Replacement patch below.
-Tony