@@ -535,6 +535,14 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip)
535
535
if (lflags & ~GPIOHANDLE_REQUEST_VALID_FLAGS )
536
536
return - EINVAL ;
537
537
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
+
538
546
/*
539
547
* Do not allow OPEN_SOURCE & OPEN_DRAIN flags in a single request. If
540
548
* the hardware actually supports enabling both at the same time the
@@ -926,7 +934,9 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
926
934
}
927
935
928
936
/* This is just wrong: we don't look for events on output lines */
929
- if (lflags & GPIOHANDLE_REQUEST_OUTPUT ) {
937
+ if ((lflags & GPIOHANDLE_REQUEST_OUTPUT ) ||
938
+ (lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN ) ||
939
+ (lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE )) {
930
940
ret = - EINVAL ;
931
941
goto out_free_label ;
932
942
}
@@ -940,10 +950,6 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
940
950
941
951
if (lflags & GPIOHANDLE_REQUEST_ACTIVE_LOW )
942
952
set_bit (FLAG_ACTIVE_LOW , & desc -> flags );
943
- if (lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN )
944
- set_bit (FLAG_OPEN_DRAIN , & desc -> flags );
945
- if (lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE )
946
- set_bit (FLAG_OPEN_SOURCE , & desc -> flags );
947
953
948
954
ret = gpiod_direction_input (desc );
949
955
if (ret )
0 commit comments