diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2006-04-25 07:46:17 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-06-21 15:04:09 -0700 |
commit | 73e487fdb75f8abf230968dbf73a3dc3b16808d3 (patch) | |
tree | 3e40b1888ec5529b2f3e9a2dfa5d5e6b47947b48 /drivers/usb/serial/console.c | |
parent | ca85485c1f482e6625f36aceb85eaaeff4b22d79 (diff) | |
download | blackbird-op-linux-73e487fdb75f8abf230968dbf73a3dc3b16808d3.tar.gz blackbird-op-linux-73e487fdb75f8abf230968dbf73a3dc3b16808d3.zip |
[PATCH] USB console: fix disconnection issues
Prevent sending further output to a USB-serial console after the dongle is
disconnected, take care not to leak kref.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/console.c')
-rw-r--r-- | drivers/usb/serial/console.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c index fc4a0f731d91..f3404e10afb4 100644 --- a/drivers/usb/serial/console.c +++ b/drivers/usb/serial/console.c @@ -202,7 +202,7 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun struct usb_serial *serial; int retval = -ENODEV; - if (!port) + if (!port || port->serial->dev->state == USB_STATE_NOTATTACHED) return; serial = port->serial; @@ -255,6 +255,14 @@ static struct console usbcons = { .index = -1, }; +void usb_serial_console_disconnect(struct usb_serial *serial) +{ + if (serial && serial->port && serial->port[0] && serial->port[0] == usbcons_info.port) { + usb_serial_console_exit(); + usb_serial_put(serial); + } +} + void usb_serial_console_init (int serial_debug, int minor) { debug = serial_debug; @@ -280,6 +288,11 @@ void usb_serial_console_init (int serial_debug, int minor) void usb_serial_console_exit (void) { - unregister_console(&usbcons); + if (usbcons_info.port) { + unregister_console(&usbcons); + if (usbcons_info.port->open_count) + usbcons_info.port->open_count--; + usbcons_info.port = NULL; + } } |