summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorKaushlendra Kumar <kaushlendra.kumar@intel.com>2025-08-13 12:32:08 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-11-13 15:34:08 -0500
commit4535b7ec16b4bd77168119788f5252886fb1bec8 (patch)
treec98a74463242d08310b7ca75fe4c1fc2d95ca58b /tools
parent1dee521b9412f19c6d7c2190a4def7474de8c4f4 (diff)
downloadlinux-4535b7ec16b4bd77168119788f5252886fb1bec8.tar.gz
linux-4535b7ec16b4bd77168119788f5252886fb1bec8.tar.bz2
linux-4535b7ec16b4bd77168119788f5252886fb1bec8.zip
tools/power x86_energy_perf_policy: Fix incorrect fopen mode usage
[ Upstream commit 62127655b7ab7b8c2997041aca48a81bf5c6da0c ] The fopen_or_die() function was previously hardcoded to open files in read-only mode ("r"), ignoring the mode parameter passed to it. This patch corrects fopen_or_die() to use the provided mode argument, allowing for flexible file access as intended. Additionally, the call to fopen_or_die() in err_on_hypervisor() incorrectly used the mode "ro", which is not a valid fopen mode. This is fixed to use the correct "r" mode. Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com> Signed-off-by: Len Brown <len.brown@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c b/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
index ebda9c366b2b..c883f211dbcc 100644
--- a/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
+++ b/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
@@ -630,7 +630,7 @@ void cmdline(int argc, char **argv)
*/
FILE *fopen_or_die(const char *path, const char *mode)
{
- FILE *filep = fopen(path, "r");
+ FILE *filep = fopen(path, mode);
if (!filep)
err(1, "%s: open failed", path);
@@ -644,7 +644,7 @@ void err_on_hypervisor(void)
char *buffer;
/* On VMs /proc/cpuinfo contains a "flags" entry for hypervisor */
- cpuinfo = fopen_or_die("/proc/cpuinfo", "ro");
+ cpuinfo = fopen_or_die("/proc/cpuinfo", "r");
buffer = malloc(4096);
if (!buffer) {