lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250721153656.5103-1-zzhwaxy.kernel@gmail.com>
Date: Mon, 21 Jul 2025 23:36:56 +0800
From: Zihuan Zhang <zzhwaxy.kernel@...il.com>
To: "Rafael J . Wysocki" <rafael@...nel.org>,
	Viresh Kumar <viresh.kumar@...aro.org>
Cc: linux-pm@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Zihuan Zhang <zzhwaxy.kernel@...il.com>
Subject: [PATCH v1] cpufreq: Avoid creating sysfs link for offline CPUs

Currently, cpufreq_add_dev() attempts to create a sysfs link
even when the target CPU is offline. Although guarded by a NULL
check on cpufreq_policy, this behavior is not strictly correct,
since offline CPUs shouldn't have their sysfs interface created.

This patch cleans up the logic to only add the sysfs link
when the CPU is online and cpufreq policy is properly initialized.

Signed-off-by: Zihuan Zhang <zzhwaxy.kernel@...il.com>
---
 drivers/cpufreq/cpufreq.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index d7426e1d8bdd..0a77892d366c 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1660,12 +1660,12 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
 		ret = cpufreq_online(cpu);
 		if (ret)
 			return ret;
-	}
 
-	/* Create sysfs link on CPU registration */
-	policy = per_cpu(cpufreq_cpu_data, cpu);
-	if (policy)
-		add_cpu_dev_symlink(policy, cpu, dev);
+		/* Create sysfs link on CPU registration */
+		policy = per_cpu(cpufreq_cpu_data, cpu);
+		if (policy)
+			add_cpu_dev_symlink(policy, cpu, dev);
+	}
 
 	return 0;
 }
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ