[LTP] [PATCH] sys_leds01: Fix max_brightness range check on 32-bit
Wake Liu
wakel@google.com
Fri Nov 13 23:54:11 CET 2026
The kernel stores max_brightness in struct led_classdev as unsigned int
and led-class.c exports it with "%u", so any value up to UINT_MAX is
valid.
The test checks it against LONG_MAX, which is only 2147483647 on 32-bit
userspace. An LED that reports a larger max_brightness, e.g. 4294967295,
makes the test fail on 32-bit while the same value passes on 64-bit.
Use TST_SYSFS_ASSERT_RANGEUU() with UINT_MAX as the upper bound. This
matches the kernel type on all architectures and follows the
tst_sysfs_assert.h guidance to use the unsigned variant for attributes
the kernel exports as an unsigned type.
Fixes: e996b5a6c2d9 ("testcases: sysfs: sys_leds01")
Signed-off-by: Wake Liu <wakel@google.com>
---
testcases/kernel/sysfs/class/leds/sys_leds01.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/testcases/kernel/sysfs/class/leds/sys_leds01.c b/testcases/kernel/sysfs/class/leds/sys_leds01.c
index 68e7f2094..50376d219 100644
--- a/testcases/kernel/sysfs/class/leds/sys_leds01.c
+++ b/testcases/kernel/sysfs/class/leds/sys_leds01.c
@@ -30,7 +30,7 @@ static void check_led(const char *name)
tst_res(TINFO, "Checking led '%s'", name);
- TST_SYSFS_ASSERT_RANGELL(1, LONG_MAX, PATH_CLASS_LEDS "/%s/max_brightness", name);
+ TST_SYSFS_ASSERT_RANGEUU(1, UINT_MAX, PATH_CLASS_LEDS "/%s/max_brightness", name);
TST_SYSFS_ASSERT_RANGELF(0, "brightness", "max_brightness",
PATH_CLASS_LEDS "/%s/", name);
--
2.56.0.611.g1030f0b940-goog
More information about the ltp
mailing list