[PATCH 094/150] USB: cdc-acm: fix device unregistration

Luis Henriques luis.henriques at canonical.com
Tue Mar 26 15:19:53 UTC 2013 -stable review patch.  If anyone has any objections, please let me know.


From: Johan Hovold <jhovold at gmail.com>

commit cb25505fc604292c70fc02143fc102f54c8595f0 upstream.

Unregister tty device in disconnect as is required by the USB stack.

By deferring unregistration to when the last tty reference is dropped,
the parent interface device can get unregistered before the child
resulting in broken hotplug events being generated when the tty is
finally closed:

KERNEL[2290.798128] remove   /devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1:3.1 (usb)
KERNEL[2290.804589] remove   /devices/pci0000:00/0000:00:1d.7/usb2/2-1 (usb)
KERNEL[2294.554799] remove   /2-1:3.1/tty/ttyACM0 (tty)

The driver must deal with tty callbacks after disconnect by checking the
disconnected flag. Specifically, further opens must be prevented and
this is already implemented.

Cc: Oliver Neukum <oneukum at suse.de>
Acked-by: Oliver Neukum <oneukum at suse.de>
Signed-off-by: Johan Hovold <jhovold at gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
Signed-off-by: Luis Henriques <luis.henriques at canonical.com>
 drivers/usb/class/cdc-acm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index ec2bba6..07a9f9c 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -601,7 +601,6 @@ static void acm_port_destruct(struct tty_port *port)
 	dev_dbg(&acm->control->dev, "%s\n", __func__);
-	tty_unregister_device(acm_tty_driver, acm->minor);
@@ -1418,6 +1417,8 @@ static void acm_disconnect(struct usb_interface *intf)
+	tty_unregister_device(acm_tty_driver, acm->minor);
 	for (i = 0; i < ACM_NW; i++)

More information about the kernel-team mailing list