diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2009-06-02 11:53:55 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-06-16 00:44:47 -0400 |
commit | f9c99bb8b3a1ec81af68d484a551307326c2e933 (patch) | |
tree | 9031ebe390ecd558d54ad484dde5ba66dcf823b7 /drivers/usb/serial/cyberjack.c | |
parent | c706ebdfc8955b850e477255a8c0f93f9f14712d (diff) |
USB: usb-serial: replace shutdown with disconnect, release
This patch (as1254) splits up the shutdown method of usb_serial_driver
into a disconnect and a release method.
The problem is that the usb-serial core was calling shutdown during
disconnect handling, but drivers didn't expect it to be called until
after all the open file references had been closed. The result was an
oops when the close method tried to use memory that had been
deallocated by shutdown.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/cyberjack.c')
-rw-r--r-- | drivers/usb/serial/cyberjack.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index 933ba913e66c..336523fd7366 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c | |||
@@ -58,7 +58,8 @@ static int debug; | |||
58 | 58 | ||
59 | /* Function prototypes */ | 59 | /* Function prototypes */ |
60 | static int cyberjack_startup(struct usb_serial *serial); | 60 | static int cyberjack_startup(struct usb_serial *serial); |
61 | static void cyberjack_shutdown(struct usb_serial *serial); | 61 | static void cyberjack_disconnect(struct usb_serial *serial); |
62 | static void cyberjack_release(struct usb_serial *serial); | ||
62 | static int cyberjack_open(struct tty_struct *tty, | 63 | static int cyberjack_open(struct tty_struct *tty, |
63 | struct usb_serial_port *port, struct file *filp); | 64 | struct usb_serial_port *port, struct file *filp); |
64 | static void cyberjack_close(struct usb_serial_port *port); | 65 | static void cyberjack_close(struct usb_serial_port *port); |
@@ -94,7 +95,8 @@ static struct usb_serial_driver cyberjack_device = { | |||
94 | .id_table = id_table, | 95 | .id_table = id_table, |
95 | .num_ports = 1, | 96 | .num_ports = 1, |
96 | .attach = cyberjack_startup, | 97 | .attach = cyberjack_startup, |
97 | .shutdown = cyberjack_shutdown, | 98 | .disconnect = cyberjack_disconnect, |
99 | .release = cyberjack_release, | ||
98 | .open = cyberjack_open, | 100 | .open = cyberjack_open, |
99 | .close = cyberjack_close, | 101 | .close = cyberjack_close, |
100 | .write = cyberjack_write, | 102 | .write = cyberjack_write, |
@@ -148,17 +150,25 @@ static int cyberjack_startup(struct usb_serial *serial) | |||
148 | return 0; | 150 | return 0; |
149 | } | 151 | } |
150 | 152 | ||
151 | static void cyberjack_shutdown(struct usb_serial *serial) | 153 | static void cyberjack_disconnect(struct usb_serial *serial) |
152 | { | 154 | { |
153 | int i; | 155 | int i; |
154 | 156 | ||
155 | dbg("%s", __func__); | 157 | dbg("%s", __func__); |
156 | 158 | ||
157 | for (i = 0; i < serial->num_ports; ++i) { | 159 | for (i = 0; i < serial->num_ports; ++i) |
158 | usb_kill_urb(serial->port[i]->interrupt_in_urb); | 160 | usb_kill_urb(serial->port[i]->interrupt_in_urb); |
161 | } | ||
162 | |||
163 | static void cyberjack_release(struct usb_serial *serial) | ||
164 | { | ||
165 | int i; | ||
166 | |||
167 | dbg("%s", __func__); | ||
168 | |||
169 | for (i = 0; i < serial->num_ports; ++i) { | ||
159 | /* My special items, the standard routines free my urbs */ | 170 | /* My special items, the standard routines free my urbs */ |
160 | kfree(usb_get_serial_port_data(serial->port[i])); | 171 | kfree(usb_get_serial_port_data(serial->port[i])); |
161 | usb_set_serial_port_data(serial->port[i], NULL); | ||
162 | } | 172 | } |
163 | } | 173 | } |
164 | 174 | ||