]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
cdc-acm: fix race between initial clearing halt and open
authorOliver Neukum <oneukum@suse.com>
Mon, 18 Aug 2025 23:13:58 +0000 (19:13 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:21:34 +0000 (16:21 +0200)
[ Upstream commit 64690a90cd7c6db16d3af8616be1f4bf8d492850 ]

On the devices that need their endpoints to get an
initial clear_halt, this needs to be done before
the devices can be opened. That means it needs to be
before the devices are registered.

Fixes: 15bf722e6f6c0 ("cdc-acm: Add support of ATOL FPrint fiscal printers")
Cc: stable <stable@kernel.org>
Signed-off-by: Oliver Neukum <oneukum@suse.com>
Link: https://lore.kernel.org/r/20250717141259.2345605-1-oneukum@suse.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/class/cdc-acm.c

index 51f2caf0fb3edc78a32cdee66eaf5bb317c478de..4730089a771b5542d7b2df88e2ecf11f9d860f74 100644 (file)
@@ -1527,6 +1527,12 @@ skip_countries:
        usb_driver_claim_interface(&acm_driver, data_interface, acm);
        usb_set_intfdata(data_interface, acm);
 
+       if (quirks & CLEAR_HALT_CONDITIONS) {
+               /* errors intentionally ignored */
+               usb_clear_halt(usb_dev, acm->in);
+               usb_clear_halt(usb_dev, acm->out);
+       }
+
        tty_dev = tty_port_register_device(&acm->port, acm_tty_driver, minor,
                        &control_interface->dev);
        if (IS_ERR(tty_dev)) {
@@ -1534,11 +1540,6 @@ skip_countries:
                goto alloc_fail6;
        }
 
-       if (quirks & CLEAR_HALT_CONDITIONS) {
-               usb_clear_halt(usb_dev, acm->in);
-               usb_clear_halt(usb_dev, acm->out);
-       }
-
        dev_info(&intf->dev, "ttyACM%d: USB ACM device\n", minor);
 
        return 0;