[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e7ea177261ded70f0c781841b0fb67fb1eb8909d.1692880423.git.maciej.wieczor-retman@intel.com>
Date: Thu, 24 Aug 2023 14:41:24 +0200
From: "Wieczor-Retman, Maciej" <maciej.wieczor-retman@...el.com>
To: linux-kernel@...r.kernel.org, reinette.chatre@...el.com,
fenghua.yu@...el.com
Cc: ilpo.jarvinen@...ux.intel.com
Subject: [PATCH 1/3] selftests/resctrl: Fix schemata write error check
Writing bitmasks to the schemata can fail when the bitmask doesn't
adhere to some constraints defined by what a particular CPU supports.
Some example of constraints are max length or being having contiguous
bits. The driver should properly return errors when any rule concerning
bitmask format is broken.
Resctrl FS returns error codes from fprintf() only when fclose() is
called. Current error checking scheme allows invalid bitmasks to be
written into schemata file and the selftest doesn't notice because the
fclose() error code isn't checked.
Add error check to the fclose() call.
Add perror() just after fprintf so a proper error message can be seen.
Signed-off-by: Wieczor-Retman, Maciej <maciej.wieczor-retman@...el.com>
---
tools/testing/selftests/resctrl/resctrlfs.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c
index bd36ee206602..a6d0b632cbc6 100644
--- a/tools/testing/selftests/resctrl/resctrlfs.c
+++ b/tools/testing/selftests/resctrl/resctrlfs.c
@@ -532,13 +532,17 @@ int write_schemata(char *ctrlgrp, char *schemata, int cpu_no, char *resctrl_val)
}
if (fprintf(fp, "%s\n", schema) < 0) {
- sprintf(reason, "Failed to write schemata in control group");
+ sprintf(reason, "fprintf() failed with error : %s",
+ strerror(errno));
fclose(fp);
ret = -1;
goto out;
}
- fclose(fp);
+ ret = fclose(fp);
+ if (ret)
+ sprintf(reason, "Failed to write schemata in control group : %s",
+ strerror(errno));
out:
ksft_print_msg("Write schema \"%s\" to resctrl FS%s%s\n",
--
2.42.0
Powered by blists - more mailing lists