From: Kent Gibson Date: Mon, 9 Sep 2019 03:22:18 +0000 (+0000) Subject: gpio: fix line flag validation in linehandle_create X-Git-Tag: v4.19.74~34 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=22ed1d47281155d5ecd39e526027c93a096325c7;p=platform%2Fkernel%2Flinux-rpi.git gpio: fix line flag validation in linehandle_create commit e95fbc130a162ba9ad956311b95aa0da269eea48 upstream. linehandle_create should not allow both GPIOHANDLE_REQUEST_INPUT and GPIOHANDLE_REQUEST_OUTPUT to be set. Fixes: d7c51b47ac11 ("gpio: userspace ABI for reading/writing GPIO lines") Cc: stable Signed-off-by: Kent Gibson Signed-off-by: Bartosz Golaszewski Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 5339585..e18d2f6 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -525,6 +525,14 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip) return -EINVAL; /* + * Do not allow both INPUT & OUTPUT flags to be set as they are + * contradictory. + */ + if ((lflags & GPIOHANDLE_REQUEST_INPUT) && + (lflags & GPIOHANDLE_REQUEST_OUTPUT)) + return -EINVAL; + + /* * Do not allow OPEN_SOURCE & OPEN_DRAIN flags in a single request. If * the hardware actually supports enabling both at the same time the * electrical result would be disastrous.