Commit 1f4a640e authored by Bartosz Golaszewski's avatar Bartosz Golaszewski
Browse files

gpiolib: fix a NULL-pointer dereference when setting direction



For optional GPIOs we may pass NULL to gpiod_direction_(input|output)().
With the call to the notifier chain added by commit 07c61d4d
("gpiolib: notify user-space about in-kernel line state changes") we
will now dereference a NULL pointer in this case. The reason for that is
the fact that the expansion of the VALIDATE_DESC() macro (which returns
0 for NULL descriptors) was moved into the nonotify variants of the
direction setters.

Move them back to the top-level interfaces as the nonotify ones are only
ever called from inside the GPIO core and are always passed valid GPIO
descriptors. This way we'll never call the line_state notifier chain
with non-valid descs.

Fixes: 07c61d4d ("gpiolib: notify user-space about in-kernel line state changes")
Reported-by: default avatarMark Brown <broonie@kernel.org>
Closes: https://lore.kernel.org/all/d6601a31-7685-4b21-9271-1b76116cc483@sirena.org.uk/


Tested-by: default avatarKlara Modin <klarasmodin@gmail.com>
Tested-by: default avatarMark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20241024133834.47395-1-brgl@bgdev.pl


Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
parent 4295f4cc
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment