Skip to content

Commit e95fbc1

Browse files
warthog618brgl
authored andcommitted
gpio: fix line flag validation in linehandle_create
linehandle_create should not allow both GPIOHANDLE_REQUEST_INPUT and GPIOHANDLE_REQUEST_OUTPUT 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 59929d3 commit e95fbc1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/gpio/gpiolib.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,14 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip)
535535
if (lflags & ~GPIOHANDLE_REQUEST_VALID_FLAGS)
536536
return -EINVAL;
537537

538+
/*
539+
* Do not allow both INPUT & OUTPUT flags to be set as they are
540+
* contradictory.
541+
*/
542+
if ((lflags & GPIOHANDLE_REQUEST_INPUT) &&
543+
(lflags & GPIOHANDLE_REQUEST_OUTPUT))
544+
return -EINVAL;
545+
538546
/*
539547
* Do not allow OPEN_SOURCE & OPEN_DRAIN flags in a single request. If
540548
* the hardware actually supports enabling both at the same time the

0 commit comments

Comments
 (0)