[tip: x86/urgent] fs/resctrl: Free mon_data structures on rdt_get_tree() failure
From: tip-bot2 for Tony Luck
Date: Mon Jul 06 2026 - 23:47:39 EST
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: ca0676ae2e1a23ac3e858224fc630b99f9e216ea
Gitweb: https://git.kernel.org/tip/ca0676ae2e1a23ac3e858224fc630b99f9e216ea
Author: Tony Luck <tony.luck@xxxxxxxxx>
AuthorDate: Mon, 06 Jul 2026 15:46:21 -07:00
Committer: Borislav Petkov (AMD) <bp@xxxxxxxxx>
CommitterDate: Mon, 06 Jul 2026 17:42:38 -07:00
fs/resctrl: Free mon_data structures on rdt_get_tree() failure
If mkdir_mondata_all() or 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_mongrp error path to free the mon_data
structures.
Fixes: 2a6566038544 ("x86/resctrl: Expand the width of domid by replacing mon_data_bits")
Closes: https://lore.kernel.org/lkml/5d38c1fb-8f91-472b-8897-24b2f50c772b@xxxxxxxxx/
Reported-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>
Signed-off-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
Reviewed-by: Chen Yu <yu.c.chen@xxxxxxxxx>
Reviewed-by: Ben Horgan <ben.horgan@xxxxxxx>
Cc: <stable@xxxxxxxxxx>
Link: https://patch.msgid.link/433623b7e3316ffd52323255d1aa4f156ad97cb1.1783377598.git.reinette.chatre@xxxxxxxxx
---
fs/resctrl/rdtgroup.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index af2cbab..1312b52 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -74,6 +74,8 @@ static int rdtgroup_setup_root(struct rdt_fs_context *ctx);
static void rdtgroup_destroy_root(void);
+static void mon_put_kn_priv(void);
+
struct dentry *debugfs_resctrl;
/*
@@ -2893,6 +2895,7 @@ out_mondata:
kernfs_remove(kn_mondata);
out_mongrp:
if (resctrl_arch_mon_capable()) {
+ mon_put_kn_priv();
rdtgroup_unassign_cntrs(&rdtgroup_default);
kernfs_remove(kn_mongrp);
}