Skip to content

Commit

Permalink
USB: cdc-acm: always claim data interface
Browse files Browse the repository at this point in the history
Make sure to always claim the data interface and bail out if binding
fails.

Note that the driver had a check to verify that the data interface was
not already bound to a driver but would not detect other failures (e.g.
if the interface was not authorised).

Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20210322155318.9837-8-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Johan Hovold authored and Greg Kroah-Hartman committed Mar 23, 2021
1 parent f8255ee commit 0b2b23c
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions drivers/usb/class/cdc-acm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1309,13 +1309,6 @@ static int acm_probe(struct usb_interface *intf,
if (!combined_interfaces && intf != control_interface)
return -ENODEV;

if (!combined_interfaces && usb_interface_claimed(data_interface)) {
/* valid in this context */
dev_dbg(&intf->dev, "The data interface isn't available\n");
return -EBUSY;
}


if (data_interface->cur_altsetting->desc.bNumEndpoints < 2 ||
control_interface->cur_altsetting->desc.bNumEndpoints == 0)
return -EINVAL;
Expand Down Expand Up @@ -1499,7 +1492,11 @@ static int acm_probe(struct usb_interface *intf,
acm->line.bDataBits = 8;
acm_set_line(acm, &acm->line);

usb_driver_claim_interface(&acm_driver, data_interface, acm);
if (!acm->combined_interfaces) {
rv = usb_driver_claim_interface(&acm_driver, data_interface, acm);
if (rv)
goto err_remove_files;
}

tty_dev = tty_port_register_device(&acm->port, acm_tty_driver, minor,
&control_interface->dev);
Expand All @@ -1521,6 +1518,7 @@ static int acm_probe(struct usb_interface *intf,
usb_set_intfdata(data_interface, NULL);
usb_driver_release_interface(&acm_driver, data_interface);
}
err_remove_files:
if (acm->country_codes) {
device_remove_file(&acm->control->dev,
&dev_attr_wCountryCodes);
Expand Down

0 comments on commit 0b2b23c

Please sign in to comment.