Skip to content

Commit 162f98d

Browse files
nefigtutdtor
authored andcommitted
Input: gtco - fix crash on detecting device without endpoints
The gtco driver expects at least one valid endpoint. If given malicious descriptors that specify 0 for the number of endpoints, it will crash in the probe function. Ensure there is at least one endpoint on the interface before using it. Also let's fix a minor coding style issue. The full correct report of this issue can be found in the public Red Hat Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1283385 Reported-by: Ralf Spenneberg <ralf@spenneberg.net> Signed-off-by: Vladis Dronov <vdronov@redhat.com> Cc: stable@vger.kernel.org Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent d314e9e commit 162f98d

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎drivers/input/tablet/gtco.c‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,14 @@ static int gtco_probe(struct usb_interface *usbinterface,
858858
goto err_free_buf;
859859
}
860860

861+
/* Sanity check that a device has an endpoint */
862+
if (usbinterface->altsetting[0].desc.bNumEndpoints < 1) {
863+
dev_err(&usbinterface->dev,
864+
"Invalid number of endpoints\n");
865+
error = -EINVAL;
866+
goto err_free_urb;
867+
}
868+
861869
/*
862870
* The endpoint is always altsetting 0, we know this since we know
863871
* this device only has one interrupt endpoint
@@ -879,7 +887,7 @@ static int gtco_probe(struct usb_interface *usbinterface,
879887
* HID report descriptor
880888
*/
881889
if (usb_get_extra_descriptor(usbinterface->cur_altsetting,
882-
HID_DEVICE_TYPE, &hid_desc) != 0){
890+
HID_DEVICE_TYPE, &hid_desc) != 0) {
883891
dev_err(&usbinterface->dev,
884892
"Can't retrieve exta USB descriptor to get hid report descriptor length\n");
885893
error = -EIO;

0 commit comments

Comments
 (0)