USB: serial: xr: fix NULL-deref at probe
authorJohan Hovold <johan@kernel.org>
Thu, 21 Jan 2021 10:29:13 +0000 (11:29 +0100)
committerJohan Hovold <johan@kernel.org>
Tue, 26 Jan 2021 15:16:14 +0000 (16:16 +0100)
Make sure that the probed device has an interface 0 to avoid
dereferencing a NULL pointer in case of a malicious device or during
USB-descriptor fuzzing.

Fixes: c2d405aa86b4 ("USB: serial: add MaxLinear/Exar USB to Serial driver")
Signed-off-by: Johan Hovold <johan@kernel.org>
drivers/usb/serial/xr_serial.c

index bdb2df27b50bfd911dda98c745da471e5a8a7e25..7be6da6a5cf3e278bb003f5c9088254dcd52488c 100644 (file)
@@ -552,6 +552,9 @@ static int xr_probe(struct usb_serial *serial, const struct usb_device_id *id)
 
        /* But claim the control interface during data interface probe */
        control_interface = usb_ifnum_to_if(usb_dev, 0);
+       if (!control_interface)
+               return -ENODEV;
+
        ret = usb_driver_claim_interface(driver, control_interface, NULL);
        if (ret) {
                dev_err(&serial->interface->dev, "Failed to claim control interface\n");