[PATCH 2/3] fs/resctrl: Return -EINVAL for a missing seq_show implementation

Aaron Tomlin posted 3 patches 5 days, 5 hours ago
[PATCH 2/3] fs/resctrl: Return -EINVAL for a missing seq_show implementation
Posted by Aaron Tomlin 5 days, 5 hours ago
The rdtgroup_seqfile_show() function, which is the sequence file handler
for reading data from resctrl files, previously returned 0 (success) if
the file's associated rftype did not define a .seq_show implementation.

This behavior is incorrect and confusing, as a read operation that
does not define a display function should be treated as an error.

This patch change the function to return -EINVAL if the file type
handler (i.e., rft->seq_show) is NULL, providing proper feedback that
the operation is invalid for that file.

Signed-off-by: Aaron Tomlin <atomlin@atomlin.com>
---
 fs/resctrl/rdtgroup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 8e39dfda56bc..e1dc63b2218f 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -314,7 +314,8 @@ static int rdtgroup_seqfile_show(struct seq_file *m, void *arg)
 
 	if (rft->seq_show)
 		return rft->seq_show(of, m, arg);
-	return 0;
+
+	return -EINVAL;
 }
 
 static ssize_t rdtgroup_file_write(struct kernfs_open_file *of, char *buf,
-- 
2.51.0