All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wake Liu via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Cc: Wake Liu <wakel@google.com>
Subject: [LTP] [PATCH] sys_leds01: Fix max_brightness range check on 32-bit
Date: Fri, 13 Nov 2026 22:54:11 +0000	[thread overview]
Message-ID: <20261113225411.3757447-1-wakel@google.com> (raw)

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


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

             reply	other threads:[~2026-11-13 22:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 22:54 Wake Liu via ltp [this message]
2026-11-13 23:56 ` [LTP] sys_leds01: Fix max_brightness range check on 32-bit linuxtestproject.agent
2026-11-16 13:22 ` [LTP] [PATCH] " Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261113225411.3757447-1-wakel@google.com \
    --to=ltp@lists.linux.it \
    --cc=wakel@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.