diff mbox series

[7/7] USB: cdc-acm: always claim data interface

Message ID 20210318155202.22230-8-johan@kernel.org
State New
Headers show
Series USB: cdc-acm: probe fixes | expand

Commit Message

Johan Hovold March 18, 2021, 3:52 p.m. UTC
Make sure to always claim the data interface and bail out if it's
already bound to another driver or isn't authorised.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/class/cdc-acm.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Oliver Neukum March 22, 2021, 10:46 a.m. UTC | #1
Am Donnerstag, den 18.03.2021, 16:52 +0100 schrieb Johan Hovold:
> Make sure to always claim the data interface and bail out if it's

> already bound to another driver or isn't authorised.


Hi,

Thanks for the fixes. All previous ones are good work.
this one is problematic I am afraid.


acm_probe() has a test for the availability of the interface:

	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;
	}

That check is ancient. BKL still existed. If you want to remove it
and do proper error handling, that would be good. But if you do
error handling, the check has to go, too.

	Regards
		Oliver
Johan Hovold March 22, 2021, 2:13 p.m. UTC | #2
On Mon, Mar 22, 2021 at 11:46:47AM +0100, Oliver Neukum wrote:
> Am Donnerstag, den 18.03.2021, 16:52 +0100 schrieb Johan Hovold:

> > Make sure to always claim the data interface and bail out if it's

> > already bound to another driver or isn't authorised.

> 

> Hi,

> 

> Thanks for the fixes. All previous ones are good work.

> this one is problematic I am afraid.

> 

> 

> acm_probe() has a test for the availability of the interface:

> 

> 	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;

> 	}

> 

> That check is ancient. BKL still existed. If you want to remove it

> and do proper error handling, that would be good. But if you do

> error handling, the check has to go, too.


Thanks, this bit can go indeed. But note that it's simply because it's
now redundant.

I'll send a v2.

Johan
diff mbox series

Patch

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 6991ffd66c5d..58c444f9db5e 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1486,7 +1486,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);
@@ -1508,6 +1512,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);