]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
zd1211rw: fix NULL-deref at probe
authorJohan Hovold <johan@kernel.org>
Mon, 13 Mar 2017 12:44:21 +0000 (13:44 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 26 Aug 2017 01:13:57 +0000 (02:13 +0100)
commit ca260ece6a57dc7d751e0685f51fa2c55d851873 upstream.

Make sure to check the number of endpoints to avoid dereferencing a
NULL-pointer or accessing memory beyond the endpoint array should a
malicious device lack the expected endpoints.

Fixes: a1030e92c150 ("[PATCH] zd1211rw: Convert installer CDROM device into WLAN device")
Cc: Daniel Drake <dsd@gentoo.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
[bwh: Backported to 3.2: adjust filename]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/net/wireless/zd1211rw/zd_usb.c

index 785bdbe38f2a0cb6f67d6ad56a3c0ad2d5980490..a67d0b29443c6d216883b68c1efba6dc4005a930 100644 (file)
@@ -1281,6 +1281,9 @@ static int eject_installer(struct usb_interface *intf)
        u8 bulk_out_ep;
        int r;
 
+       if (iface_desc->desc.bNumEndpoints < 2)
+               return -ENODEV;
+
        /* Find bulk out endpoint */
        for (r = 1; r >= 0; r--) {
                endpoint = &iface_desc->endpoint[r].desc;