[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <nycvar.YFH.7.76.2408292151350.12664@cbobk.fhfr.pm>
Date: Thu, 29 Aug 2024 21:51:47 +0200 (CEST)
From: Jiri Kosina <jikos@...nel.org>
To: Dan Carpenter <dan.carpenter@...aro.org>
cc: Charles Wang <charles.goodix@...il.com>,
Benjamin Tissoires <bentiss@...nel.org>,
Dmitry Torokhov <dmitry.torokhov@...il.com>, linux-input@...r.kernel.org,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [PATCH v2 next] HID: hid-goodix: Fix type promotion bug in
goodix_hid_get_raw_report()
On Thu, 29 Aug 2024, Dan Carpenter wrote:
> The issue is GOODIX_HID_PKG_LEN_SIZE is defined as sizeof(u16) which is
> type size_t. However, goodix_hid_check_ack_status() returns negative
> error codes or potentially a positive but invalid length which is too
> small. So when we compare "if ((response_data_len <=
> GOODIX_HID_PKG_LEN_SIZE)" then negative error codes are type promoted to
> size_t and counted as a positive large value and treated as valid.
>
> It would have been easy enough to add some casting to avoid the type
> promotion, however this patch takes a more thourough approach and moves
> the length check into goodix_hid_check_ack_status(). Now the function
> only return negative error codes or zero on success and the length
> pointer is never set to an invalid length.
>
> Fixes: 75e16c8ce283 ("HID: hid-goodix: Add Goodix HID-over-SPI driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@...aro.org>
Good catch Dan, applied, thanks!
--
Jiri Kosina
SUSE Labs
Powered by blists - more mailing lists