diff options
author | Johan Hovold <johan@kernel.org> | 2021-01-21 11:29:13 +0100 |
---|---|---|
committer | Johan Hovold <johan@kernel.org> | 2021-01-26 16:16:14 +0100 |
commit | a38d21488097f9823ebd297d56b24f431ee7acaa (patch) | |
tree | 5a57b091adefa614470b9be1fd87af021a499e4d /drivers/usb/serial/xr_serial.c | |
parent | USB: serial: mos7840: fix error code in mos7840_write() (diff) | |
download | linux-a38d21488097f9823ebd297d56b24f431ee7acaa.tar.xz linux-a38d21488097f9823ebd297d56b24f431ee7acaa.zip |
USB: serial: xr: fix NULL-deref at probe
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>
Diffstat (limited to 'drivers/usb/serial/xr_serial.c')
-rw-r--r-- | drivers/usb/serial/xr_serial.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/usb/serial/xr_serial.c b/drivers/usb/serial/xr_serial.c index bdb2df27b50b..7be6da6a5cf3 100644 --- a/drivers/usb/serial/xr_serial.c +++ b/drivers/usb/serial/xr_serial.c @@ -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"); |