Skip to content
/ linux Public

Commit b74bf7d

Browse files
gnoackSasha Levin
authored andcommitted
HID: logitech-hidpp: Check maxfield in hidpp_get_report_length()
[ Upstream commit 1547d41 ] Do not crash when a report has no fields. Fake USB gadgets can send their own HID report descriptors and can define report structures without valid fields. This can be used to crash the kernel over USB. Cc: stable@vger.kernel.org Signed-off-by: Günther Noack <gnoack@google.com> Signed-off-by: Jiri Kosina <jkosina@suse.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 3f1b21c commit b74bf7d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/hid/hid-logitech-hidpp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4339,7 +4339,7 @@ static int hidpp_get_report_length(struct hid_device *hdev, int id)
43394339

43404340
re = &(hdev->report_enum[HID_OUTPUT_REPORT]);
43414341
report = re->report_id_hash[id];
4342-
if (!report)
4342+
if (!report || !report->maxfield)
43434343
return 0;
43444344

43454345
return report->field[0]->report_count + 1;

0 commit comments

Comments
 (0)