[Devel] [PATCH vz10 16/24] drivers/base/cpu: fix cpu/offline content inside a ve

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jul 6 13:59:54 MSK 2026


print_cpus_offline()'s non-super-ve early return passed len (declared
0 at that point, used later only as the sysfs_emit_at() accumulator)
as snprintf()'s size argument, so nothing was ever written to buf.
Since sysfs zeroes the page before calling show(), reading
/sys/devices/system/cpu/offline from inside a ve returned a single
NUL byte instead of the intended empty line ("\n").

Fixes: 13cc6987a961 ("ve/cpu: handle sysfs attributes for CTs")
Feature: sysfs: per-CT entries visibility and permissions configuration
https://virtuozzo.atlassian.net/browse/VSTOR-137234
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 drivers/base/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 1e992254b12c..b7ddc8346603 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -263,7 +263,7 @@ static ssize_t print_cpus_offline(struct device *dev,
 	cpumask_var_t offline;
 
 	if (!ve_is_super(get_exec_env()))
-		return snprintf(buf, len, "\n");
+		return sysfs_emit(buf, "\n");
 
 	/* display offline cpus < nr_cpu_ids */
 	if (!alloc_cpumask_var(&offline, GFP_KERNEL))
-- 
2.47.1



More information about the Devel mailing list