diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2006-04-25 01:46:17 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-06-21 18:04:09 -0400 |
commit | 73e487fdb75f8abf230968dbf73a3dc3b16808d3 (patch) | |
tree | 3e40b1888ec5529b2f3e9a2dfa5d5e6b47947b48 /drivers/usb/serial/console.c | |
parent | ca85485c1f482e6625f36aceb85eaaeff4b22d79 (diff) |
[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 | |||
202 | struct usb_serial *serial; | 202 | struct usb_serial *serial; |
203 | int retval = -ENODEV; | 203 | int retval = -ENODEV; |
204 | 204 | ||
205 | if (!port) | 205 | if (!port || port->serial->dev->state == USB_STATE_NOTATTACHED) |
206 | return; | 206 | return; |
207 | serial = port->serial; | 207 | serial = port->serial; |
208 | 208 | ||
@@ -255,6 +255,14 @@ static struct console usbcons = { | |||
255 | .index = -1, | 255 | .index = -1, |
256 | }; | 256 | }; |
257 | 257 | ||
258 | void usb_serial_console_disconnect(struct usb_serial *serial) | ||
259 | { | ||
260 | if (serial && serial->port && serial->port[0] && serial->port[0] == usbcons_info.port) { | ||
261 | usb_serial_console_exit(); | ||
262 | usb_serial_put(serial); | ||
263 | } | ||
264 | } | ||
265 | |||
258 | void usb_serial_console_init (int serial_debug, int minor) | 266 | void usb_serial_console_init (int serial_debug, int minor) |
259 | { | 267 | { |
260 | debug = serial_debug; | 268 | debug = serial_debug; |
@@ -280,6 +288,11 @@ void usb_serial_console_init (int serial_debug, int minor) | |||
280 | 288 | ||
281 | void usb_serial_console_exit (void) | 289 | void usb_serial_console_exit (void) |
282 | { | 290 | { |
283 | unregister_console(&usbcons); | 291 | if (usbcons_info.port) { |
292 | unregister_console(&usbcons); | ||
293 | if (usbcons_info.port->open_count) | ||
294 | usbcons_info.port->open_count--; | ||
295 | usbcons_info.port = NULL; | ||
296 | } | ||
284 | } | 297 | } |
285 | 298 | ||