Skip to content

Commit f164f5d

Browse files
committed
USB: serial: xr: fix NULL-deref on disconnect
Claiming the sibling control interface is a bit more involved and specifically requires adding support to USB-serial core for managing either interface being unbound first, something which could otherwise lead to a NULL-pointer dereference. Similarly, additional infrastructure is also needed to handle suspend properly. Since the driver currently isn't actually using the control interface, we can defer this for now by simply not claiming the control interface. Fixes: c2d405a ("USB: serial: add MaxLinear/Exar USB to Serial driver") Reported-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Tested-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Manivannan Sadhasivam <mani@kernel.org> Signed-off-by: Johan Hovold <johan@kernel.org>
1 parent 42213a0 commit f164f5d

1 file changed

Lines changed: 0 additions & 25 deletions

File tree

drivers/usb/serial/xr_serial.c

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -545,37 +545,13 @@ static void xr_close(struct usb_serial_port *port)
545545

546546
static int xr_probe(struct usb_serial *serial, const struct usb_device_id *id)
547547
{
548-
struct usb_driver *driver = serial->type->usb_driver;
549-
struct usb_interface *control_interface;
550-
int ret;
551-
552548
/* Don't bind to control interface */
553549
if (serial->interface->cur_altsetting->desc.bInterfaceNumber == 0)
554550
return -ENODEV;
555551

556-
/* But claim the control interface during data interface probe */
557-
control_interface = usb_ifnum_to_if(serial->dev, 0);
558-
if (!control_interface)
559-
return -ENODEV;
560-
561-
ret = usb_driver_claim_interface(driver, control_interface, NULL);
562-
if (ret) {
563-
dev_err(&serial->interface->dev, "Failed to claim control interface\n");
564-
return ret;
565-
}
566-
567552
return 0;
568553
}
569554

570-
static void xr_disconnect(struct usb_serial *serial)
571-
{
572-
struct usb_driver *driver = serial->type->usb_driver;
573-
struct usb_interface *control_interface;
574-
575-
control_interface = usb_ifnum_to_if(serial->dev, 0);
576-
usb_driver_release_interface(driver, control_interface);
577-
}
578-
579555
static const struct usb_device_id id_table[] = {
580556
{ USB_DEVICE(0x04e2, 0x1410) }, /* XR21V141X */
581557
{ }
@@ -590,7 +566,6 @@ static struct usb_serial_driver xr_device = {
590566
.id_table = id_table,
591567
.num_ports = 1,
592568
.probe = xr_probe,
593-
.disconnect = xr_disconnect,
594569
.open = xr_open,
595570
.close = xr_close,
596571
.break_ctl = xr_break_ctl,

0 commit comments

Comments
 (0)