From: Johan Hovold Date: Tue, 14 Jan 2020 08:27:29 +0000 (+0100) Subject: r8152: add missing endpoint sanity check X-Git-Tag: Ubuntu-4.15.0-89.89~488 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=66f6c6581a487d7c3e007615eb48d9ecb84c5c08;p=mirror_ubuntu-bionic-kernel.git r8152: add missing endpoint sanity check BugLink: https://bugs.launchpad.net/bugs/1862259 [ Upstream commit 86f3f4cd53707ceeec079b83205c8d3c756eca93 ] 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 Signed-off-by: Johan Hovold Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Signed-off-by: Kamal Mostafa Signed-off-by: Khalid Elmously --- diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 658ebb46a450..1caf3f7085fe 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -5211,6 +5211,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) {