]> www.infradead.org Git - users/jedix/linux-maple.git/commit
leds: leds-st1202: Fix NULL pointer access on race condition
authorManuel Fombuena <fombuena@outlook.com>
Tue, 25 Feb 2025 22:01:02 +0000 (22:01 +0000)
committerLee Jones <lee@kernel.org>
Fri, 28 Feb 2025 09:18:37 +0000 (09:18 +0000)
commitc72e455b89f216b43cd0dbb518036ec4c98f5c46
treec9cdbe1ac25ce2352b58d76714fb816eaa6bb38c
parent2014c95afecee3e76ca4a56956a936e23283f05b
leds: leds-st1202: Fix NULL pointer access on race condition

st1202_dt_init() calls devm_led_classdev_register_ext() before the
internal data structures are properly set up, so the LEDs become visible
to user space while being partially initialized, leading to a window
where trying to access them causes a NULL pointer access.

Move devm_led_classdev_register_ext() from DT initialization
to the end of the probe function when DT and hardware are fully
initialized and ready to interact with user space.

Fixes: 259230378c65 ("leds: Add LED1202 I2C driver")
Signed-off-by: Manuel Fombuena <fombuena@outlook.com>
Link: https://lore.kernel.org/r/CWLP123MB54732771AC0CE5491B3C84DCC5C32@CWLP123MB5473.GBRP123.PROD.OUTLOOK.COM
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/leds/leds-st1202.c