gpio: fix line flag validation in lineevent_create
PATCH 1/1 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.
--- drivers/gpio/gpiolib.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/gpio/gpiolib.c +4 -6
@@ -918,7 +918,7 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip) goto out_free_label; } -/* Return an error if a unknown flag is set */ +/* Return an error if an unknown flag is set */ if ((lflags & ~GPIOHANDLE_REQUEST_VALID_FLAGS ) || (eflags & ~GPIOEVENT_REQUEST_VALID_FLAGS )) { ret = -EINVAL ;
@@ -926,7 +926,9 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip) }/* This is just wrong: we don't look for events on output lines */ -if (lflags &GPIOHANDLE_REQUEST_OUTPUT ) { +if ((lflags &GPIOHANDLE_REQUEST_OUTPUT ) || + (lflags &GPIOHANDLE_REQUEST_OPEN_DRAIN ) || + (lflags &GPIOHANDLE_REQUEST_OPEN_SOURCE )) { ret = -EINVAL ; goto out_free_label; }
@@ -940,10 +942,6 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)if (lflags &GPIOHANDLE_REQUEST_ACTIVE_LOW )set_bit (FLAG_ACTIVE_LOW , &desc->flags); -if (lflags &GPIOHANDLE_REQUEST_OPEN_DRAIN ) -set_bit (FLAG_OPEN_DRAIN , &desc->flags); -if (lflags &GPIOHANDLE_REQUEST_OPEN_SOURCE ) -set_bit (FLAG_OPEN_SOURCE , &desc->flags); ret =gpiod_direction_input (desc);if (ret)
Signature · 1 line
2.23.0
pon., 9 wrz 2019 o 05:24 Kent Gibson <[email protected]> napisał(a):
Quoted 1 line
Hi Kent,
thanks for spotting this. Just single nit below:
Quoted 13 lines
lineevent_createshould not allow any ofGPIOHANDLE_REQUEST_OUTPUT,GPIOHANDLE_REQUEST_OPEN_DRAINorGPIOHANDLE_REQUEST_OPEN_SOURCEto be set.Signed-off-by Kent Gibson <[email protected]>--- drivers/gpio/gpiolib.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)drivers/gpio/gpiolib.c +0
-0
drivers/gpio/gpiolib.c static int lineevent_create(struct gpio_device *gdev, void __user *ip) · line 921
Quoted 5 lines
drivers/gpio/gpiolib.c +1
-1@@ -918,7 +918,7 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip) goto out_free_label; } -/* Return an error if a unknown flag is set */ +/* Return an error if an unknown flag is set */
Please don't sneak in changes unrelated to the patch. If you want to fix the typo - do it in a separate one.
Quoted 28 lines
drivers/gpio/gpiolib.c +3
-6if ((lflags & ~GPIOHANDLE_REQUEST_VALID_FLAGS ) || (eflags & ~GPIOEVENT_REQUEST_VALID_FLAGS )) { ret = -EINVAL ;@@ -926,7 +926,9 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip) }/* This is just wrong: we don't look for events on output lines */ -if (lflags &GPIOHANDLE_REQUEST_OUTPUT ) { +if ((lflags &GPIOHANDLE_REQUEST_OUTPUT ) || + (lflags &GPIOHANDLE_REQUEST_OPEN_DRAIN ) || + (lflags &GPIOHANDLE_REQUEST_OPEN_SOURCE )) { ret = -EINVAL ; goto out_free_label; }@@ -940,10 +942,6 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)if (lflags &GPIOHANDLE_REQUEST_ACTIVE_LOW )set_bit (FLAG_ACTIVE_LOW , &desc->flags); -if (lflags &GPIOHANDLE_REQUEST_OPEN_DRAIN ) -set_bit (FLAG_OPEN_DRAIN , &desc->flags); -if (lflags &GPIOHANDLE_REQUEST_OPEN_SOURCE ) -set_bit (FLAG_OPEN_SOURCE , &desc->flags); ret =gpiod_direction_input (desc);if (ret) --2.23.0
pon., 9 wrz 2019 o 09:31 Bartosz Golaszewski <[email protected]> napisał(a):
Quoted 53 lines
pon., 9 wrz 2019 o 05:24 Kent Gibson <[email protected]> napisał(a):
Quoted 1 line
Hi Kent,
thanks for spotting this. Just single nit below:
Quoted 13 lines
lineevent_createshould not allow any ofGPIOHANDLE_REQUEST_OUTPUT,GPIOHANDLE_REQUEST_OPEN_DRAINorGPIOHANDLE_REQUEST_OPEN_SOURCEto be set.Signed-off-by Kent Gibson <[email protected]>--- drivers/gpio/gpiolib.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)drivers/gpio/gpiolib.c +0
-0drivers/gpio/gpiolib.c static int lineevent_create(struct gpio_device *gdev, void __user *ip) · line 921
Quoted 5 lines
drivers/gpio/gpiolib.c +1
-1@@ -918,7 +918,7 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip) goto out_free_label; } -/* Return an error if a unknown flag is set */ +/* Return an error if an unknown flag is set */ Please don't sneak in changes unrelated to the patch. If you want to fix the typo - do it in a separate one.
Quoted 23 lines
drivers/gpio/gpiolib.c +3
-5if ((lflags & ~GPIOHANDLE_REQUEST_VALID_FLAGS ) || (eflags & ~GPIOEVENT_REQUEST_VALID_FLAGS )) { ret = -EINVAL ;@@ -926,7 +926,9 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip) }/* This is just wrong: we don't look for events on output lines */ -if (lflags &GPIOHANDLE_REQUEST_OUTPUT ) { +if ((lflags &GPIOHANDLE_REQUEST_OUTPUT ) || + (lflags &GPIOHANDLE_REQUEST_OPEN_DRAIN ) || + (lflags &GPIOHANDLE_REQUEST_OPEN_SOURCE )) { ret = -EINVAL ; goto out_free_label; }@@ -940,10 +942,6 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)if (lflags &GPIOHANDLE_REQUEST_ACTIVE_LOW )set_bit (FLAG_ACTIVE_LOW , &desc->flags); -if (lflags &GPIOHANDLE_REQUEST_OPEN_DRAIN ) -set_bit (FLAG_OPEN_DRAIN , &desc->flags); -if (lflags &GPIOHANDLE_REQUEST_OPEN_SOURCE ) -set_bit (FLAG_OPEN_SOURCE , &desc->flags);
Quoted 5 lines
Quoted 5 lines
drivers/gpio/gpiolib.c +0
-1ret =gpiod_direction_input (desc);if (ret) --2.23.0
Ok, so seeing that we'll still have another week for fixes, I thought it would be nice to get those in before v5.3. I eventually applied both patches and simply removed the typo fix.
Bart