aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2020-01-14 09:27:29 +0100
committerDavid S. Miller <davem@davemloft.net>2020-01-14 18:43:21 -0800
commit86f3f4cd53707ceeec079b83205c8d3c756eca93 (patch)
treefc0ca9cf35e8a6cf065344a9548e3a3ade6bf31e
parenthv_sock: Remove the accept port restriction (diff)
downloadlinux-dev-86f3f4cd53707ceeec079b83205c8d3c756eca93.tar.xz
linux-dev-86f3f4cd53707ceeec079b83205c8d3c756eca93.zip
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 <hayeswang@realtek.com> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/usb/r8152.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index c5ebf35d2488..031cb8fff909 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) {