From: Johan Hovold Date: Tue, 14 Jan 2020 08:27:29 +0000 (+0100) Subject: r8152: add missing endpoint sanity check X-Git-Tag: baikal/mips/sdk5.9~14532^2~27 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=df5ee46b73fb35024cf721b32d928ff99fe247a9;p=kernel.git 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: f5859f6e3744 ("net/usb/r8152: enable interrupt transfer") Cc: hayeswang Signed-off-by: Johan Hovold Signed-off-by: David S. Miller --- diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index c5ebf35d24884..031cb8fff9094 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -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) {