linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] input: uinput: Drop checks for abs_min > abs_max
@ 2023-12-18 17:16 Chris Morgan
  2023-12-19 23:51 ` Peter Hutterer
  0 siblings, 1 reply; 12+ messages in thread
From: Chris Morgan @ 2023-12-18 17:16 UTC (permalink / raw)
  To: linux-input
  Cc: dmitry.torokhov, svv, biswarupp, peter.hutterer, paul, contact,
	Chris Morgan

From: Chris Morgan <macromorgan@hotmail.com>

Stop checking if the minimum abs value is greater than the maximum abs
value. When the axis is inverted this condition is allowed. Without
relaxing this check, it is not possible to use uinput on devices in
userspace with an inverted axis, such as the adc-joystick found on
many handheld gaming devices.

Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
---
 drivers/input/misc/uinput.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index d98212d55108..e90dbf2c0b34 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -403,14 +403,7 @@ static int uinput_validate_absinfo(struct input_dev *dev, unsigned int code,
 	min = abs->minimum;
 	max = abs->maximum;
 
-	if ((min != 0 || max != 0) && max < min) {
-		printk(KERN_DEBUG
-		       "%s: invalid abs[%02x] min:%d max:%d\n",
-		       UINPUT_NAME, code, min, max);
-		return -EINVAL;
-	}
-
-	if (!check_sub_overflow(max, min, &range) && abs->flat > range) {
+	if (!check_sub_overflow(max, min, &range) && abs->flat > abs(range)) {
 		printk(KERN_DEBUG
 		       "%s: abs_flat #%02x out of range: %d (min:%d/max:%d)\n",
 		       UINPUT_NAME, code, abs->flat, min, max);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-01-03 23:22 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-18 17:16 [PATCH] input: uinput: Drop checks for abs_min > abs_max Chris Morgan
2023-12-19 23:51 ` Peter Hutterer
2023-12-20  0:38   ` Paul Cercueil
2023-12-20  1:53     ` Dmitry Torokhov
2023-12-20 13:39       ` Paul Cercueil
2023-12-22 17:09         ` Chris Morgan
2024-01-03 23:22           ` Peter Hutterer
2023-12-23 14:29         ` Hans de Goede
2023-12-23 15:01           ` Paul Cercueil
2023-12-23 15:16             ` Hans de Goede
2023-12-24  8:03               ` Dmitry Torokhov
2023-12-30  5:32                 ` Chris Morgan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).