HID: logitech-hidpp: Check maxfield in hidpp_get_report_length()

[ Upstream commit 1547d41f9f ]

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>
This commit is contained in:
Günther Noack
2026-01-09 13:25:58 +01:00
committed by Sasha Levin
parent e7ac1cd823
commit f1ceaaf93e
+1 -1
View File
@@ -4341,7 +4341,7 @@ static int hidpp_get_report_length(struct hid_device *hdev, int id)
re = &(hdev->report_enum[HID_OUTPUT_REPORT]);
report = re->report_id_hash[id];
if (!report)
if (!report || !report->maxfield)
return 0;
return report->field[0]->report_count + 1;