[tip: x86/cache] fs/resctrl: Use accurate and symmetric exit flows
From: tip-bot2 for Reinette Chatre
Date: Mon Jul 27 2026 - 14:37:23 EST
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 7a8c45106b68d76e3815fe45266b61821810e0bd
Gitweb: https://git.kernel.org/tip/7a8c45106b68d76e3815fe45266b61821810e0bd
Author: Reinette Chatre <reinette.chatre@xxxxxxxxx>
AuthorDate: Tue, 30 Jun 2026 21:27:06 -07:00
Committer: Borislav Petkov (AMD) <bp@xxxxxxxxx>
CommitterDate: Sat, 25 Jul 2026 13:50:02 -07:00
fs/resctrl: Use accurate and symmetric exit flows
During schemata file write handling there is one error exit path labeled
"out" that handles all cleanup and unlocking needed on exit. The staged
configs cleared during an error exit may not have been used at the time
of exit making the clearing of the staged configs unnecessary.
Access the exit code using two labels and only clear the staged
configuration if it was in use at the time of exit. Doing so makes the
code flow obvious and simplifies upcoming changes that improve the
handling of failures during early input parsing.
Signed-off-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
Reviewed-by: Tony Luck <tony.luck@xxxxxxxxx>
Tested-by: Babu Moger <babu.moger@xxxxxxx>
Link: https://patch.msgid.link/4cdd79d612dc6d62ccd490e1c31298025d66d385.1782857711.git.reinette.chatre@xxxxxxxxx
---
fs/resctrl/ctrlmondata.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c
index 2b29fb5..e6ad892 100644
--- a/fs/resctrl/ctrlmondata.c
+++ b/fs/resctrl/ctrlmondata.c
@@ -331,7 +331,7 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKED) {
ret = -EINVAL;
rdt_last_cmd_puts("Resource group is pseudo-locked\n");
- goto out;
+ goto out_unlock;
}
rdt_staged_configs_clear();
@@ -341,16 +341,16 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
if (!tok) {
rdt_last_cmd_puts("Missing ':'\n");
ret = -EINVAL;
- goto out;
+ goto out_clear_staged;
}
if (tok[0] == '\0') {
rdt_last_cmd_printf("Missing '%s' value\n", resname);
ret = -EINVAL;
- goto out;
+ goto out_clear_staged;
}
ret = rdtgroup_parse_resource(resname, tok, rdtgrp);
if (ret)
- goto out;
+ goto out_clear_staged;
}
list_for_each_entry(s, &resctrl_schema_all, list) {
@@ -365,7 +365,7 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
ret = resctrl_arch_update_domains(r, rdtgrp->closid);
if (ret)
- goto out;
+ goto out_clear_staged;
}
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) {
@@ -378,8 +378,9 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
ret = rdtgroup_pseudo_lock_create(rdtgrp);
}
-out:
+out_clear_staged:
rdt_staged_configs_clear();
+out_unlock:
rdtgroup_kn_unlock(of->kn);
return ret ?: nbytes;
}