Skip to content

Commit 1547d41

Browse files
gnoackJiri Kosina
authored andcommitted
HID: logitech-hidpp: Check maxfield in hidpp_get_report_length()
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>
1 parent cee8337 commit 1547d41

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/hid/hid-logitech-hidpp.c

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

43154315
re = &(hdev->report_enum[HID_OUTPUT_REPORT]);
43164316
report = re->report_id_hash[id];
4317-
if (!report)
4317+
if (!report || !report->maxfield)
43184318
return 0;
43194319

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

0 commit comments

Comments
 (0)