Skip to content

Commit a8eeb74

Browse files
jhovolddtor
authored andcommitted
Input: gtco - fix endpoint sanity check
The driver was checking the number of endpoints of the first alternate setting instead of the current one, something which could lead to the driver binding to an invalid interface. This in turn could cause the driver to misbehave or trigger a WARN() in usb_submit_urb() that kernels with panic_on_warn set would choke on. Fixes: 162f98d ("Input: gtco - fix crash on detecting device without endpoints") Signed-off-by: Johan Hovold <[email protected]> Acked-by: Vladis Dronov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent cfa4f6a commit a8eeb74

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

drivers/input/tablet/gtco.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -875,18 +875,14 @@ static int gtco_probe(struct usb_interface *usbinterface,
875875
}
876876

877877
/* Sanity check that a device has an endpoint */
878-
if (usbinterface->altsetting[0].desc.bNumEndpoints < 1) {
878+
if (usbinterface->cur_altsetting->desc.bNumEndpoints < 1) {
879879
dev_err(&usbinterface->dev,
880880
"Invalid number of endpoints\n");
881881
error = -EINVAL;
882882
goto err_free_urb;
883883
}
884884

885-
/*
886-
* The endpoint is always altsetting 0, we know this since we know
887-
* this device only has one interrupt endpoint
888-
*/
889-
endpoint = &usbinterface->altsetting[0].endpoint[0].desc;
885+
endpoint = &usbinterface->cur_altsetting->endpoint[0].desc;
890886

891887
/* Some debug */
892888
dev_dbg(&usbinterface->dev, "gtco # interfaces: %d\n", usbinterface->num_altsetting);
@@ -973,7 +969,7 @@ static int gtco_probe(struct usb_interface *usbinterface,
973969
input_dev->dev.parent = &usbinterface->dev;
974970

975971
/* Setup the URB, it will be posted later on open of input device */
976-
endpoint = &usbinterface->altsetting[0].endpoint[0].desc;
972+
endpoint = &usbinterface->cur_altsetting->endpoint[0].desc;
977973

978974
usb_fill_int_urb(gtco->urbinfo,
979975
udev,

0 commit comments

Comments
 (0)