All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Morgan <macroalpha82@gmail.com>
To: linux-input@vger.kernel.org
Cc: dmitry.torokhov@gmail.com, svv@google.com, biswarupp@google.com,
	peter.hutterer@who-t.net, paul@crapouillou.net,
	contact@artur-rojek.eu, Chris Morgan <macromorgan@hotmail.com>
Subject: [PATCH] input: uinput: Drop checks for abs_min > abs_max
Date: Mon, 18 Dec 2023 11:16:53 -0600	[thread overview]
Message-ID: <20231218171653.141941-1-macroalpha82@gmail.com> (raw)

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


             reply	other threads:[~2023-12-18 17:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-18 17:16 Chris Morgan [this message]
2023-12-19 23:51 ` [PATCH] input: uinput: Drop checks for abs_min > abs_max 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231218171653.141941-1-macroalpha82@gmail.com \
    --to=macroalpha82@gmail.com \
    --cc=biswarupp@google.com \
    --cc=contact@artur-rojek.eu \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=macromorgan@hotmail.com \
    --cc=paul@crapouillou.net \
    --cc=peter.hutterer@who-t.net \
    --cc=svv@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.