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: c2d405aa86 ("USB: serial: add MaxLinear/Exar USB to Serial driver")
Signed-off-by: Johan Hovold <johan@kernel.org>
This commit is contained in:
Johan Hovold 2021-01-21 11:29:13 +01:00
parent a70aa7dc60
commit a38d214880
1 changed files with 3 additions and 0 deletions

View 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 */ /* But claim the control interface during data interface probe */
control_interface = usb_ifnum_to_if(usb_dev, 0); control_interface = usb_ifnum_to_if(usb_dev, 0);
if (!control_interface)
return -ENODEV;
ret = usb_driver_claim_interface(driver, control_interface, NULL); ret = usb_driver_claim_interface(driver, control_interface, NULL);
if (ret) { if (ret) {
dev_err(&serial->interface->dev, "Failed to claim control interface\n"); dev_err(&serial->interface->dev, "Failed to claim control interface\n");