Skip to content

Commit 8d8e95f

Browse files
jhovolddavem330
authored andcommitted
net: lan78xx: add missing endpoint sanity check
Add the missing endpoint sanity check to prevent a NULL-pointer dereference should a malicious device lack the expected endpoints. Note that the driver has a broken endpoint-lookup helper, lan78xx_get_endpoints(), which can end up accepting interfaces in an altsetting without endpoints as long as *some* altsetting has a bulk-in and a bulk-out endpoint. Fixes: 55d7de9 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver") Cc: [email protected] <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e911e99 commit 8d8e95f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/net/usb/lan78xx.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3759,6 +3759,11 @@ static int lan78xx_probe(struct usb_interface *intf,
37593759
netdev->max_mtu = MAX_SINGLE_PACKET_SIZE;
37603760
netif_set_gso_max_size(netdev, MAX_SINGLE_PACKET_SIZE - MAX_HEADER);
37613761

3762+
if (intf->cur_altsetting->desc.bNumEndpoints < 3) {
3763+
ret = -ENODEV;
3764+
goto out3;
3765+
}
3766+
37623767
dev->ep_blkin = (intf->cur_altsetting)->endpoint + 0;
37633768
dev->ep_blkout = (intf->cur_altsetting)->endpoint + 1;
37643769
dev->ep_intr = (intf->cur_altsetting)->endpoint + 2;

0 commit comments

Comments
 (0)