diff options
| author | Dan Carpenter <[email protected]> | 2024-08-29 19:30:39 +0000 |
|---|---|---|
| committer | Jiri Kosina <[email protected]> | 2024-08-29 19:49:22 +0000 |
| commit | 252ed1f7f7c657812ee864a9dad0a935f7bed08b (patch) | |
| tree | 85ce807e75ab32065ef282d3124f506b2a6f068e /lib/crypto/mpi/mpi-mul.c | |
| parent | dt-bindings: input: Goodix SPI HID Touchscreen (diff) | |
| download | kernel-252ed1f7f7c657812ee864a9dad0a935f7bed08b.tar.gz kernel-252ed1f7f7c657812ee864a9dad0a935f7bed08b.zip | |
HID: hid-goodix: Fix type promotion bug in goodix_hid_get_raw_report()
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 <[email protected]>
Reviewed-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Jiri Kosina <[email protected]>
Diffstat (limited to 'lib/crypto/mpi/mpi-mul.c')
0 files changed, 0 insertions, 0 deletions
