Commit 8084d92d authored by Johan Hovold's avatar Johan Hovold Committed by Khalid Elmously

r8152: add missing endpoint sanity check

BugLink: https://bugs.launchpad.net/bugs/1860681

[ Upstream commit 86f3f4cd ]

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: 40a82917 ("net/usb/r8152: enable interrupt transfer")
Cc: hayeswang <hayeswang@realtek.com>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 9822c4fc
...@@ -4322,6 +4322,9 @@ static int rtl8152_probe(struct usb_interface *intf, ...@@ -4322,6 +4322,9 @@ static int rtl8152_probe(struct usb_interface *intf,
return -ENODEV; return -ENODEV;
} }
if (intf->cur_altsetting->desc.bNumEndpoints < 3)
return -ENODEV;
usb_reset_device(udev); usb_reset_device(udev);
netdev = alloc_etherdev(sizeof(struct r8152)); netdev = alloc_etherdev(sizeof(struct r8152));
if (!netdev) { if (!netdev) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment