[PATCH mpam mpam/snapshot+extras/v6.17-rc2 1/2] fs/resctrl: Fix the iommu_group parsing process

From: Zeng Heng

Date: Fri Nov 07 2025 - 01:33:08 EST


When the tasks interface receives the iommu_group:id configuration, it
should return after completing its parsing, and continue to the next
token, rather than erroneously proceeding directly to pid parsing.
Otherwise, an EINVAL error is returned.

This fix supports processing multiple consecutive iommu_group:id and pid
configurations.

Signed-off-by: Zeng Heng <zengheng4@xxxxxxxxxx>
---
fs/resctrl/rdtgroup.c | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 839d568b8798..4f4468e11dca 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -854,24 +854,33 @@ static ssize_t rdtgroup_tasks_write(struct kernfs_open_file *of,
pid_str = strim(strsep(&buf, ","));

is_iommu = string_is_iommu_group(pid_str, &iommu_group_id);
- if (is_iommu)
+ if (is_iommu) {
ret = rdtgroup_move_iommu(iommu_group_id, rdtgrp, of);
- else if (kstrtoint(pid_str, 0, &pid)) {
- rdt_last_cmd_printf("Task list parsing error pid %s\n", pid_str);
- ret = -EINVAL;
- break;
- }
+ if (ret) {
+ rdt_last_cmd_printf("Error while processing iommu_group %d\n",
+ iommu_group_id);
+ break;
+ }
+ } else {
+ if (kstrtoint(pid_str, 0, &pid)) {
+ rdt_last_cmd_printf("Task list parsing error pid %s\n",
+ pid_str);
+ ret = -EINVAL;
+ break;
+ }

- if (pid < 0) {
- rdt_last_cmd_printf("Invalid pid %d\n", pid);
- ret = -EINVAL;
- break;
- }
+ if (pid < 0) {
+ rdt_last_cmd_printf("Invalid pid %d\n", pid);
+ ret = -EINVAL;
+ break;
+ }

- ret = rdtgroup_move_task(pid, rdtgrp, of);
- if (ret) {
- rdt_last_cmd_printf("Error while processing task %d\n", pid);
- break;
+ ret = rdtgroup_move_task(pid, rdtgrp, of);
+ if (ret) {
+ rdt_last_cmd_printf("Error while processing task %d\n",
+ pid);
+ break;
+ }
}
}

--
2.25.1