public inbox for linux-input@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] HID: hid-lenovo-go-s: Multiple bug fixes
@ 2026-02-27 20:54 Ethan Tidmore
  2026-02-27 20:54 ` [PATCH 1/3] HID: hid-lenovo-go-s: Fix signedness bug Ethan Tidmore
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Ethan Tidmore @ 2026-02-27 20:54 UTC (permalink / raw)
  To: Derek J . Clark, Mark Pearson, Jiri Kosina
  Cc: Benjamin Tissoires, Mario Limonciello, linux-input, linux-kernel,
	Ethan Tidmore

Here are three simple bug fixes found with Smatch.

Ethan Tidmore (3):
  HID: hid-lenovo-go-s: Fix signedness bug
  HID: hid-lenovo-go-s: Remove impossible condition
  HID: hid-lenovo-go-s: Fix positive promotion bug

 drivers/hid/hid-lenovo-go-s.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

-- 
2.53.0


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

* [PATCH 1/3] HID: hid-lenovo-go-s: Fix signedness bug
  2026-02-27 20:54 [PATCH 0/3] HID: hid-lenovo-go-s: Multiple bug fixes Ethan Tidmore
@ 2026-02-27 20:54 ` Ethan Tidmore
  2026-03-06  5:57   ` Derek John Clark
  2026-02-27 20:54 ` [PATCH 2/3] HID: hid-lenovo-go-s: Remove impossible condition Ethan Tidmore
  2026-02-27 20:54 ` [PATCH 3/3] HID: hid-lenovo-go-s: Fix positive promotion bug Ethan Tidmore
  2 siblings, 1 reply; 7+ messages in thread
From: Ethan Tidmore @ 2026-02-27 20:54 UTC (permalink / raw)
  To: Derek J . Clark, Mark Pearson, Jiri Kosina
  Cc: Benjamin Tissoires, Mario Limonciello, linux-input, linux-kernel,
	Ethan Tidmore

The function get_endpoint_address() returns type u8 but in its error
path returns -ENODEV. Also, every variable that is assigned from this
function is type int.

Change return type to int from u8.

Detected by Smatch:
drivers/hid/hid-lenovo-go-s.c:391 get_endpoint_address() warn:
signedness bug returning '(-19)'

Fixes: 4325fdab5dbbf ("HID: hid-lenovo-go-s: Add Lenovo Legion Go S Series HID Driver")
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
---
 drivers/hid/hid-lenovo-go-s.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-lenovo-go-s.c b/drivers/hid/hid-lenovo-go-s.c
index cacc5bd5ed2b..0ef98ba68d86 100644
--- a/drivers/hid/hid-lenovo-go-s.c
+++ b/drivers/hid/hid-lenovo-go-s.c
@@ -377,7 +377,7 @@ static int hid_gos_set_event_return(struct command_report *cmd_rep)
 	return 0;
 }
 
-static u8 get_endpoint_address(struct hid_device *hdev)
+static int get_endpoint_address(struct hid_device *hdev)
 {
 	struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
 	struct usb_host_endpoint *ep;
-- 
2.53.0


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

* [PATCH 2/3] HID: hid-lenovo-go-s: Remove impossible condition
  2026-02-27 20:54 [PATCH 0/3] HID: hid-lenovo-go-s: Multiple bug fixes Ethan Tidmore
  2026-02-27 20:54 ` [PATCH 1/3] HID: hid-lenovo-go-s: Fix signedness bug Ethan Tidmore
@ 2026-02-27 20:54 ` Ethan Tidmore
  2026-03-06  5:57   ` Derek John Clark
  2026-02-27 20:54 ` [PATCH 3/3] HID: hid-lenovo-go-s: Fix positive promotion bug Ethan Tidmore
  2 siblings, 1 reply; 7+ messages in thread
From: Ethan Tidmore @ 2026-02-27 20:54 UTC (permalink / raw)
  To: Derek J . Clark, Mark Pearson, Jiri Kosina
  Cc: Benjamin Tissoires, Mario Limonciello, linux-input, linux-kernel,
	Ethan Tidmore

The variable val is of type u8, so it can only be 0-255.

Remove this condition.

Detected by Smatch:
drivers/hid/hid-lenovo-go-s.c:508 gamepad_property_store() warn:
impossible condition '(val > 255) => (0-255 > 255)'

Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
---
 drivers/hid/hid-lenovo-go-s.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/hid/hid-lenovo-go-s.c b/drivers/hid/hid-lenovo-go-s.c
index 0ef98ba68d86..a24737170f83 100644
--- a/drivers/hid/hid-lenovo-go-s.c
+++ b/drivers/hid/hid-lenovo-go-s.c
@@ -504,9 +504,6 @@ static ssize_t gamepad_property_store(struct device *dev,
 		ret = kstrtou8(buf, 10, &val);
 		if (ret)
 			return ret;
-
-		if (val < 0 || val > 255)
-			return -EINVAL;
 		break;
 	case FEATURE_IMU_ENABLE:
 		ret = sysfs_match_string(feature_enabled_text, buf);
-- 
2.53.0


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

* [PATCH 3/3] HID: hid-lenovo-go-s: Fix positive promotion bug
  2026-02-27 20:54 [PATCH 0/3] HID: hid-lenovo-go-s: Multiple bug fixes Ethan Tidmore
  2026-02-27 20:54 ` [PATCH 1/3] HID: hid-lenovo-go-s: Fix signedness bug Ethan Tidmore
  2026-02-27 20:54 ` [PATCH 2/3] HID: hid-lenovo-go-s: Remove impossible condition Ethan Tidmore
@ 2026-02-27 20:54 ` Ethan Tidmore
  2026-03-06  5:57   ` Derek John Clark
  2 siblings, 1 reply; 7+ messages in thread
From: Ethan Tidmore @ 2026-02-27 20:54 UTC (permalink / raw)
  To: Derek J . Clark, Mark Pearson, Jiri Kosina
  Cc: Benjamin Tissoires, Mario Limonciello, linux-input, linux-kernel,
	Ethan Tidmore

The function mcu_property_out() returns type int and returns negative
error codes. The variable count is assigned from it and checked with
(count < 0) but this check would always be false because count can
never be less than zero as it is size_t.

Change count to ssize_t.

Detected by Smatch:
drivers/hid/hid-lenovo-go-s.c:583 gamepad_property_show() warn:
unsigned 'count' is never less than zero.

drivers/hid/hid-lenovo-go-s.c:583 gamepad_property_show() warn:
error code type promoted to positive: 'count'

Fixes: 14651777fd675 ("HID: hid-lenovo-go-s: Add Feature Status Attributes")
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
---
 drivers/hid/hid-lenovo-go-s.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-lenovo-go-s.c b/drivers/hid/hid-lenovo-go-s.c
index a24737170f83..4596c18037a9 100644
--- a/drivers/hid/hid-lenovo-go-s.c
+++ b/drivers/hid/hid-lenovo-go-s.c
@@ -573,7 +573,7 @@ static ssize_t gamepad_property_show(struct device *dev,
 				     struct device_attribute *attr, char *buf,
 				     enum feature_status_index index)
 {
-	size_t count = 0;
+	ssize_t count = 0;
 	u8 i;
 
 	count = mcu_property_out(drvdata.hdev, GET_GAMEPAD_CFG, index, 0, 0);
-- 
2.53.0


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

* Re: [PATCH 1/3] HID: hid-lenovo-go-s: Fix signedness bug
  2026-02-27 20:54 ` [PATCH 1/3] HID: hid-lenovo-go-s: Fix signedness bug Ethan Tidmore
@ 2026-03-06  5:57   ` Derek John Clark
  0 siblings, 0 replies; 7+ messages in thread
From: Derek John Clark @ 2026-03-06  5:57 UTC (permalink / raw)
  To: Ethan Tidmore
  Cc: Mark Pearson, Jiri Kosina, Benjamin Tissoires, Mario Limonciello,
	linux-input, linux-kernel

On Fri, Feb 27, 2026 at 12:55 PM Ethan Tidmore <ethantidmore06@gmail.com> wrote:
>
> The function get_endpoint_address() returns type u8 but in its error
> path returns -ENODEV. Also, every variable that is assigned from this
> function is type int.
>
> Change return type to int from u8.
>
> Detected by Smatch:
> drivers/hid/hid-lenovo-go-s.c:391 get_endpoint_address() warn:
> signedness bug returning '(-19)'
>
> Fixes: 4325fdab5dbbf ("HID: hid-lenovo-go-s: Add Lenovo Legion Go S Series HID Driver")
> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
> ---
>  drivers/hid/hid-lenovo-go-s.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hid/hid-lenovo-go-s.c b/drivers/hid/hid-lenovo-go-s.c
> index cacc5bd5ed2b..0ef98ba68d86 100644
> --- a/drivers/hid/hid-lenovo-go-s.c
> +++ b/drivers/hid/hid-lenovo-go-s.c
> @@ -377,7 +377,7 @@ static int hid_gos_set_event_return(struct command_report *cmd_rep)
>         return 0;
>  }
>
> -static u8 get_endpoint_address(struct hid_device *hdev)
> +static int get_endpoint_address(struct hid_device *hdev)
>  {
>         struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
>         struct usb_host_endpoint *ep;
> --
> 2.53.0
>
Hmm, odd that I did this correctly in the Go driver.
Thanks.

Reviewed-by: Derek J. Clark <derekjohn.clark@gmail.com>

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

* Re: [PATCH 2/3] HID: hid-lenovo-go-s: Remove impossible condition
  2026-02-27 20:54 ` [PATCH 2/3] HID: hid-lenovo-go-s: Remove impossible condition Ethan Tidmore
@ 2026-03-06  5:57   ` Derek John Clark
  0 siblings, 0 replies; 7+ messages in thread
From: Derek John Clark @ 2026-03-06  5:57 UTC (permalink / raw)
  To: Ethan Tidmore
  Cc: Mark Pearson, Jiri Kosina, Benjamin Tissoires, Mario Limonciello,
	linux-input, linux-kernel

On Fri, Feb 27, 2026 at 12:55 PM Ethan Tidmore <ethantidmore06@gmail.com> wrote:
>
> The variable val is of type u8, so it can only be 0-255.
>
> Remove this condition.
>
> Detected by Smatch:
> drivers/hid/hid-lenovo-go-s.c:508 gamepad_property_store() warn:
> impossible condition '(val > 255) => (0-255 > 255)'
>
> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
> ---
>  drivers/hid/hid-lenovo-go-s.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/drivers/hid/hid-lenovo-go-s.c b/drivers/hid/hid-lenovo-go-s.c
> index 0ef98ba68d86..a24737170f83 100644
> --- a/drivers/hid/hid-lenovo-go-s.c
> +++ b/drivers/hid/hid-lenovo-go-s.c
> @@ -504,9 +504,6 @@ static ssize_t gamepad_property_store(struct device *dev,
>                 ret = kstrtou8(buf, 10, &val);
>                 if (ret)
>                         return ret;
> -
> -               if (val < 0 || val > 255)
> -                       return -EINVAL;
>                 break;
>         case FEATURE_IMU_ENABLE:
>                 ret = sysfs_match_string(feature_enabled_text, buf);
> --
> 2.53.0
>

Reviewed-by: Derek J. Clark <derekjohn.clark@gmail.com>

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

* Re: [PATCH 3/3] HID: hid-lenovo-go-s: Fix positive promotion bug
  2026-02-27 20:54 ` [PATCH 3/3] HID: hid-lenovo-go-s: Fix positive promotion bug Ethan Tidmore
@ 2026-03-06  5:57   ` Derek John Clark
  0 siblings, 0 replies; 7+ messages in thread
From: Derek John Clark @ 2026-03-06  5:57 UTC (permalink / raw)
  To: Ethan Tidmore
  Cc: Mark Pearson, Jiri Kosina, Benjamin Tissoires, Mario Limonciello,
	linux-input, linux-kernel

On Fri, Feb 27, 2026 at 12:55 PM Ethan Tidmore <ethantidmore06@gmail.com> wrote:
>
> The function mcu_property_out() returns type int and returns negative
> error codes. The variable count is assigned from it and checked with
> (count < 0) but this check would always be false because count can
> never be less than zero as it is size_t.
>
> Change count to ssize_t.
>
> Detected by Smatch:
> drivers/hid/hid-lenovo-go-s.c:583 gamepad_property_show() warn:
> unsigned 'count' is never less than zero.
>
> drivers/hid/hid-lenovo-go-s.c:583 gamepad_property_show() warn:
> error code type promoted to positive: 'count'
>
> Fixes: 14651777fd675 ("HID: hid-lenovo-go-s: Add Feature Status Attributes")
> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
> ---
>  drivers/hid/hid-lenovo-go-s.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hid/hid-lenovo-go-s.c b/drivers/hid/hid-lenovo-go-s.c
> index a24737170f83..4596c18037a9 100644
> --- a/drivers/hid/hid-lenovo-go-s.c
> +++ b/drivers/hid/hid-lenovo-go-s.c
> @@ -573,7 +573,7 @@ static ssize_t gamepad_property_show(struct device *dev,
>                                      struct device_attribute *attr, char *buf,
>                                      enum feature_status_index index)
>  {
> -       size_t count = 0;
> +       ssize_t count = 0;
>         u8 i;
>
>         count = mcu_property_out(drvdata.hdev, GET_GAMEPAD_CFG, index, 0, 0);
> --
> 2.53.0
>

Reviewed-by: Derek J. Clark <derekjohn.clark@gmail.com>

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

end of thread, other threads:[~2026-03-06  5:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-27 20:54 [PATCH 0/3] HID: hid-lenovo-go-s: Multiple bug fixes Ethan Tidmore
2026-02-27 20:54 ` [PATCH 1/3] HID: hid-lenovo-go-s: Fix signedness bug Ethan Tidmore
2026-03-06  5:57   ` Derek John Clark
2026-02-27 20:54 ` [PATCH 2/3] HID: hid-lenovo-go-s: Remove impossible condition Ethan Tidmore
2026-03-06  5:57   ` Derek John Clark
2026-02-27 20:54 ` [PATCH 3/3] HID: hid-lenovo-go-s: Fix positive promotion bug Ethan Tidmore
2026-03-06  5:57   ` Derek John Clark

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox