]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
HID: logitech-hidpp: Check maxfield in hidpp_get_report_length()
authorGünther Noack <gnoack@google.com>
Fri, 9 Jan 2026 12:25:58 +0000 (13:25 +0100)
committerJiri Kosina <jkosina@suse.com>
Sat, 10 Jan 2026 09:29:37 +0000 (10:29 +0100)
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>
drivers/hid/hid-logitech-hidpp.c

index e871f1729d4b3072c1e21ba1eaa7e00519925946..d0a38eff9cfa866d49cafd1045882ab4164a09c9 100644 (file)
@@ -4314,7 +4314,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;