From: Johan Hovold Date: Tue, 14 Jan 2020 08:27:29 +0000 (+0100) Subject: r8152: add missing endpoint sanity check X-Git-Tag: v4.19.98~30 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a0fa9c75631f0c53835c2e08a36c926f6de8c164;p=platform%2Fkernel%2Flinux-rpi.git r8152: add missing endpoint sanity check [ 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 --- diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 91d47a7..db817d3 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -5167,6 +5167,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) {