mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 01:32:21 +02:00
HID: picolcd: prevent NULL pointer dereference in picolcd_send_and_wait()
In picolcd_send_and_wait(), an integer overflow of the signed loop counter
'k' can theoretically lead to a NULL pointer dereference of 'raw_data'.
If the loop executes more than INT_MAX times, 'k' becomes negative,
making the condition 'k < size' true even when 'size' is 0.
Change the type of 'k' to 'unsigned int' to prevent the overflow and
eliminate the out-of-bounds access.
Found by Linux Verification Center (linuxtesting.org) with the Svace static
analysis tool.
[jkosina@suse.com: extended hash length]
Fixes: fabdbf2fd2 ("HID: picoLCD: split driver code")
Signed-off-by: Georgiy Osokin <g.osokin@auroraos.dev>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
This commit is contained in:
parent
75fe87e19d
commit
0021eb0904
|
|
@ -72,7 +72,8 @@ struct picolcd_pending *picolcd_send_and_wait(struct hid_device *hdev,
|
|||
struct picolcd_pending *work;
|
||||
struct hid_report *report = picolcd_out_report(report_id, hdev);
|
||||
unsigned long flags;
|
||||
int i, j, k;
|
||||
int i, j;
|
||||
unsigned int k;
|
||||
|
||||
if (!report || !data)
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user