Skip to contentSkip to conversation

r8152: add missing endpoint sanity check

PATCH In review Johan Hovold 2 participants 2 messages Jan 14, 2020 – Jan 15, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 r8152: add missing endpoint sanity check

Add missing endpoint sanity check to probe in order to prevent a NULL-pointer dereference (or slab out-of-bounds access) when retrieving the interrupt-endpoint bInterval on ndo_open() in case a device lacks the expected endpoints.

Fixes 40a82917b1d3 ("net/usb/r8152: enable interrupt transfer")
Cc hayeswang <[email protected]>
---
 drivers/net/usb/r8152.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/usb/r8152.c +3 -0
index c5ebf35d2488..031cb8fff909 100644
@@ -6597,6 +6597,9 @@ static int rtl8152_probe(struct usb_interface *intf,
 		return -ENODEV;
 	}
 
+	if (intf->cur_altsetting->desc.bNumEndpoints < 3)
+		return -ENODEV;
+
 	usb_reset_device(udev);
 	netdev = alloc_etherdev(sizeof(struct r8152));
 	if (!netdev) {
Signature · 1 line
2.24.1
maintainer
#1 lore raw

From: Johan Hovold <[email protected]>
Date: Tue, 14 Jan 2020 09:27:29 +0100

Quoted 8 lines

Add missing endpoint sanity check to probe in order to prevent a NULL-pointer dereference (or slab out-of-bounds access) when retrieving the interrupt-endpoint bInterval on ndo_open() in case a device lacks the expected endpoints.

Fixes 40a82917b1d3 ("net/usb/r8152: enable interrupt transfer")
Cc hayeswang <[email protected]>

Applied and queued up for -stable, thank you.