Re: [PATCH 3/3] HID: hid-lenovo-go-s: Fix positive promotion bug

From: Derek John Clark

Date: Fri Mar 06 2026 - 00:58:19 EST


On Fri, Feb 27, 2026 at 12:55 PM Ethan Tidmore <ethantidmore06@xxxxxxxxx> 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@xxxxxxxxx>
> ---
> 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@xxxxxxxxx>