mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 05:48:40 +00:00
gpiolib: don't dereference a desc before validation
The fix restores a proper validation of an input gpio desc, which
might be needed to deal with optional GPIOs correctly.
Fixes: 02e479808b
("gpio: Alter semantics of *raw* operations to actually be raw")
Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
fe13862c9c
commit
30322bcf82
1 changed files with 2 additions and 1 deletions
|
@ -2437,7 +2437,7 @@ EXPORT_SYMBOL_GPL(gpiod_direction_output_raw);
|
||||||
*/
|
*/
|
||||||
int gpiod_direction_output(struct gpio_desc *desc, int value)
|
int gpiod_direction_output(struct gpio_desc *desc, int value)
|
||||||
{
|
{
|
||||||
struct gpio_chip *gc = desc->gdev->chip;
|
struct gpio_chip *gc;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
VALIDATE_DESC(desc);
|
VALIDATE_DESC(desc);
|
||||||
|
@ -2454,6 +2454,7 @@ int gpiod_direction_output(struct gpio_desc *desc, int value)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gc = desc->gdev->chip;
|
||||||
if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) {
|
if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) {
|
||||||
/* First see if we can enable open drain in hardware */
|
/* First see if we can enable open drain in hardware */
|
||||||
ret = gpio_set_drive_single_ended(gc, gpio_chip_hwgpio(desc),
|
ret = gpio_set_drive_single_ended(gc, gpio_chip_hwgpio(desc),
|
||||||
|
|
Loading…
Reference in a new issue