Commit 252ed1f
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: 75e16c8 ("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]>1 parent 9184b17 commit 252ed1f
1 file changed
+15
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
338 | | - | |
| 338 | + | |
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
| 343 | + | |
343 | 344 | | |
344 | 345 | | |
345 | 346 | | |
| |||
349 | 350 | | |
350 | 351 | | |
351 | 352 | | |
352 | | - | |
353 | | - | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
354 | 362 | | |
355 | 363 | | |
356 | 364 | | |
| |||
383 | 391 | | |
384 | 392 | | |
385 | 393 | | |
386 | | - | |
| 394 | + | |
387 | 395 | | |
388 | 396 | | |
389 | 397 | | |
| |||
434 | 442 | | |
435 | 443 | | |
436 | 444 | | |
437 | | - | |
438 | | - | |
439 | | - | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
440 | 448 | | |
441 | 449 | | |
442 | 450 | | |
| |||
0 commit comments