Skip to content

Commit 92461f5

Browse files
jhovolddtor
authored andcommitted
Input: sur40 - validate number of endpoints before using them
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer or accessing memory that lie beyond the end of the endpoint array should a malicious device lack the expected endpoints. Fixes: bdb5c57 ("Input: add sur40 driver for Samsung SUR40... ") Signed-off-by: Johan Hovold <[email protected]> Cc: [email protected] # 3.13 Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent cb1b494 commit 92461f5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/input/touchscreen/sur40.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,9 @@ static int sur40_probe(struct usb_interface *interface,
527527
if (iface_desc->desc.bInterfaceClass != 0xFF)
528528
return -ENODEV;
529529

530+
if (iface_desc->desc.bNumEndpoints < 5)
531+
return -ENODEV;
532+
530533
/* Use endpoint #4 (0x86). */
531534
endpoint = &iface_desc->endpoint[4].desc;
532535
if (endpoint->bEndpointAddress != TOUCH_ENDPOINT)

0 commit comments

Comments
 (0)