Skip to content

Commit 5ca2f54

Browse files
warthog618brgl
authored andcommitted
gpio: fix line flag validation in lineevent_create
lineevent_create should not allow any of GPIOHANDLE_REQUEST_OUTPUT, GPIOHANDLE_REQUEST_OPEN_DRAIN or GPIOHANDLE_REQUEST_OPEN_SOURCE to be set. Fixes: d7c51b4 ("gpio: userspace ABI for reading/writing GPIO lines") Cc: stable <[email protected]> Signed-off-by: Kent Gibson <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent e95fbc1 commit 5ca2f54

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

drivers/gpio/gpiolib.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,9 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
934934
}
935935

936936
/* This is just wrong: we don't look for events on output lines */
937-
if (lflags & GPIOHANDLE_REQUEST_OUTPUT) {
937+
if ((lflags & GPIOHANDLE_REQUEST_OUTPUT) ||
938+
(lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN) ||
939+
(lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE)) {
938940
ret = -EINVAL;
939941
goto out_free_label;
940942
}
@@ -948,10 +950,6 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
948950

949951
if (lflags & GPIOHANDLE_REQUEST_ACTIVE_LOW)
950952
set_bit(FLAG_ACTIVE_LOW, &desc->flags);
951-
if (lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN)
952-
set_bit(FLAG_OPEN_DRAIN, &desc->flags);
953-
if (lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE)
954-
set_bit(FLAG_OPEN_SOURCE, &desc->flags);
955953

956954
ret = gpiod_direction_input(desc);
957955
if (ret)

0 commit comments

Comments
 (0)