The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure
@ 2026-05-07 20:17 Tony Luck
  2026-05-07 20:21 ` Luck, Tony
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Tony Luck @ 2026-05-07 20:17 UTC (permalink / raw)
  To: Fenghua Yu, Reinette Chatre, Maciej Wieczor-Retman, Peter Newman,
	James Morse, Babu Moger, Drew Fustini, Dave Martin, Chen Yu
  Cc: Borislav Petkov, x86, linux-kernel, patches, Tony Luck

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.

Fixes: ee4f0ec938ad ("fs/resctrl: Simplify allocation of mon_data structures")
Reported-by: Reinette Chatre <reinette.chatre@intel.com>
Assisted-by: GitHub Copilot CLI:claude-sonnet-4.6
Signed-off-by: Tony Luck <tony.luck@intel.com>
---

Did I really need AI to help, no. But I wanted to see if it can at least
save me from some typing. Here's the prompt I used (contains just as
much typed content as this change!)

  Reinette Chatre <reinette.chatre@intel.com> reported a problem in
  rdt_get_tree(). If the mkdir_mondata_all() succeeds, the some memory
  is allocated by mon_get_kn_priv(). If a subsequent call in rdt_get_tree()
  fails, then a call to mon_put_kn_priv() is needed to free any mon_data
  structures.

  Create and apply a patch to fix this. Research a suitable Fixes: tag.
  Give credit to Reinette for reporting. Add a correctly formatted
  Assisted-by: tag with AI model version. Keep the commit comment
  concise.

 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 5dfdaa6f9d8f..aad573b62fd7 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -2879,8 +2879,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();
 		kernfs_remove(kn_mondata);
+	}
 out_mongrp:
 	if (resctrl_arch_mon_capable()) {
 		rdtgroup_unassign_cntrs(&rdtgroup_default);
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-05-10  4:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-07 20:17 [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure Tony Luck
2026-05-07 20:21 ` Luck, Tony
2026-05-07 20:43 ` Reinette Chatre
2026-05-09 17:21 ` kernel test robot
2026-05-09 18:18 ` kernel test robot
2026-05-09 18:53 ` kernel test robot
2026-05-09 20:25 ` kernel test robot
2026-05-10  4:27 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox