Files
linux/drivers/gpio
Dan Carpenter 64407f4b58 gpiolib: Fix Oops in gpiod_direction_input_nonotify()
The gpiod_direction_input_nonotify() function is supposed to return zero
if the direction for the pin is input.  But instead it accidentally
returns GPIO_LINE_DIRECTION_IN (1) which will be cast into an ERR_PTR()
in gpiochip_request_own_desc().  The callers dereference it and it leads
to a crash.

I changed gpiod_direction_output_raw_commit() just for consistency but
returning GPIO_LINE_DIRECTION_OUT (0) is fine.

Cc: stable@vger.kernel.org
Fixes: 9d846b1aeb ("gpiolib: check the return value of gpio_chip::get_direction()")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/254f3925-3015-4c9d-aac5-bb9b4b2cd2c5@stanley.mountain
[Bartosz: moved the variable declarations to the top of the functions]
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-02-28 16:30:48 +01:00
..
2024-10-21 09:23:20 +02:00
2024-10-17 08:53:34 +02:00
2021-04-14 10:19:22 +01:00
2024-10-21 09:23:34 +02:00
2023-10-13 08:39:30 +02:00
2021-05-05 16:07:41 +02:00
2022-10-26 14:52:01 +02:00
2024-11-13 16:29:27 +01:00
2023-08-21 10:39:58 +02:00
2023-03-06 12:33:02 +02:00
2019-12-09 10:40:18 +01:00
2025-02-05 14:37:53 +01:00
2024-09-30 10:16:26 +02:00