Commit 64407f4
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: 9d846b1 ("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>1 parent d082ecb commit 64407f4
1 file changed
+10
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2712 | 2712 | | |
2713 | 2713 | | |
2714 | 2714 | | |
2715 | | - | |
| 2715 | + | |
2716 | 2716 | | |
2717 | 2717 | | |
2718 | 2718 | | |
| |||
2740 | 2740 | | |
2741 | 2741 | | |
2742 | 2742 | | |
2743 | | - | |
| 2743 | + | |
2744 | 2744 | | |
2745 | | - | |
2746 | | - | |
| 2745 | + | |
| 2746 | + | |
2747 | 2747 | | |
2748 | | - | |
| 2748 | + | |
2749 | 2749 | | |
2750 | 2750 | | |
2751 | 2751 | | |
| |||
2764 | 2764 | | |
2765 | 2765 | | |
2766 | 2766 | | |
2767 | | - | |
| 2767 | + | |
2768 | 2768 | | |
2769 | 2769 | | |
2770 | 2770 | | |
| |||
2788 | 2788 | | |
2789 | 2789 | | |
2790 | 2790 | | |
2791 | | - | |
| 2791 | + | |
2792 | 2792 | | |
2793 | | - | |
2794 | | - | |
| 2793 | + | |
| 2794 | + | |
2795 | 2795 | | |
2796 | | - | |
| 2796 | + | |
2797 | 2797 | | |
2798 | 2798 | | |
2799 | 2799 | | |
| |||
0 commit comments