From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10D9D34403A; Wed, 3 Dec 2025 16:23:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764779006; cv=none; b=DKC6QmfwngsbasVHEwNX/oUjQdL10zu6iLnPG9qYYn9x5EweXcuqz2I6rO/cHWIBgyYcg5Shs8wpMEg8et0GdrpO6X0cQE92H0iIYsqnJ+FZgoFlfKfXnrmnmf4LRTQ21JqBkwwbak1XBPsLGtV72DtETzVkBbu1QsveojupDk4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764779006; c=relaxed/simple; bh=m9AkIv5mJ6w5Dh6bWRdOguZzeWavzy43/H1JcjvwtlI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QVybhISaxRIkYTGKhtyRSFsrJ/IOqfn4nTiMcO62QEjIZmg2McCCIJPQDHw1H9nE5QRYVeIVrCiOmhZbz0rj6PxBSKzR8fW7WjboJnFKJ/uDGx1dYCDJYBU8moiteko9rjpLXo0UOhv4+L12ZFS/JGttoOlvLdOZbdoK3w/SGXM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=vdwYQOp2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="vdwYQOp2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE745C4CEF5; Wed, 3 Dec 2025 16:23:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1764779005; bh=m9AkIv5mJ6w5Dh6bWRdOguZzeWavzy43/H1JcjvwtlI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vdwYQOp2rSO5kMp8HQ0o/tB4+J2bStqHOlvU22aFLbQnZmPvbxRB3dIcW+6uiyZAi 4XZQDBKKZ3LDEk6jAQ8PEmNh5sVMpv5ZDB72JpNcqAN2lmU1aQnQdJuMp+6X7EqfFA rWgD8lQQQmvGCrKDXA8l9DIYgUOuDnzDYQH7I6Nc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kaushlendra Kumar , Len Brown , Sasha Levin Subject: [PATCH 6.1 126/568] tools/power x86_energy_perf_policy: Fix incorrect fopen mode usage Date: Wed, 3 Dec 2025 16:22:08 +0100 Message-ID: <20251203152445.344358706@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251203152440.645416925@linuxfoundation.org> References: <20251203152440.645416925@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kaushlendra Kumar [ 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 Signed-off-by: Len Brown Signed-off-by: Sasha Levin --- .../power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c | 4 ++-- 1 file 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 ebda9c366b2ba..c883f211dbcc9 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) { -- 2.51.0