[PATCH v2 2/3] platform/x86: dell-laptop: Don't use an unread keyboard state at init
From: Rosen Penev
Date: Fri Nov 20 2026 - 19:10:36 EST
kbd_init_info() ignores the return value of kbd_get_state(). If the
call fails, the uninitialized state on the stack is used to set
kbd_previous_level and kbd_previous_mode_bit, which are later sent to
the BIOS when triggers are enabled or the backlight is turned back on.
kbd_get_info() has already succeeded at that point, so a failure here
may well be transient and is not a reason to give up on the keyboard
backlight. Start from level 0 and the off mode instead: the code below
then picks level 1 and the first supported mode, as it already does
when the backlight is off at boot.
Fixes: 02b2aaaa57ab ("platform: x86: dell-laptop: Add support for keyboard backlight")
Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
---
v2: fall back to level 0 / off mode instead of returning the error
drivers/platform/x86/dell/dell-laptop.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/x86/dell/dell-laptop.c b/drivers/platform/x86/dell/dell-laptop.c
index c1a51bf95c25..eca348497ac3 100644
--- a/drivers/platform/x86/dell/dell-laptop.c
+++ b/drivers/platform/x86/dell/dell-laptop.c
@@ -1455,7 +1455,7 @@ static inline int kbd_init_info(void)
dell_smbios_find_token(KBD_LED_AC_TOKEN))
kbd_timeout_ac_supported = true;
- kbd_get_state(&state);
+ ret = kbd_get_state(&state);
/* NOTE: timeout value is stored in 6 bits so max value is 63 */
if (kbd_info.seconds > 63)
@@ -1472,8 +1472,13 @@ static inline int kbd_init_info(void)
*/
kbd_info.modes &= ~BIT(KBD_MODE_BIT_ON);
- kbd_previous_level = kbd_get_level(&state);
- kbd_previous_mode_bit = state.mode_bit;
+ if (ret == 0) {
+ kbd_previous_level = kbd_get_level(&state);
+ kbd_previous_mode_bit = state.mode_bit;
+ } else {
+ kbd_previous_level = 0;
+ kbd_previous_mode_bit = KBD_MODE_BIT_OFF;
+ }
if (kbd_previous_level == 0 && kbd_get_max_level() != 0)
kbd_previous_level = 1;
--
2.56.1