mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-29 15:43:59 +08:00
USB: usb_wwan: fix urb leak at shutdown
The delayed-write queue was never emptied at shutdown (close), something
which could lead to leaked urbs if the port is closed before being
runtime resumed due to a write.
When this happens the output buffer would not drain on close
(closing_wait timeout), and after consecutive opens, writes could be
corrupted with previously buffered data, transfered with reduced
throughput or completely blocked.
Note that unbusy_queued_urb() was simply moved out of CONFIG_PM.
Fixes: 383cedc3bb
("USB: serial: full autosuspend support for the
option driver")
Cc: <stable@vger.kernel.org> # v2.6.32
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
170fad9e22
commit
79eed03e77
@ -414,12 +414,26 @@ int usb_wwan_open(struct tty_struct *tty, struct usb_serial_port *port)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(usb_wwan_open);
|
EXPORT_SYMBOL(usb_wwan_open);
|
||||||
|
|
||||||
|
static void unbusy_queued_urb(struct urb *urb,
|
||||||
|
struct usb_wwan_port_private *portdata)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < N_OUT_URB; i++) {
|
||||||
|
if (urb == portdata->out_urbs[i]) {
|
||||||
|
clear_bit(i, &portdata->out_busy);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void usb_wwan_close(struct usb_serial_port *port)
|
void usb_wwan_close(struct usb_serial_port *port)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct usb_serial *serial = port->serial;
|
struct usb_serial *serial = port->serial;
|
||||||
struct usb_wwan_port_private *portdata;
|
struct usb_wwan_port_private *portdata;
|
||||||
struct usb_wwan_intf_private *intfdata = port->serial->private;
|
struct usb_wwan_intf_private *intfdata = port->serial->private;
|
||||||
|
struct urb *urb;
|
||||||
|
|
||||||
portdata = usb_get_serial_port_data(port);
|
portdata = usb_get_serial_port_data(port);
|
||||||
|
|
||||||
@ -428,6 +442,14 @@ void usb_wwan_close(struct usb_serial_port *port)
|
|||||||
portdata->opened = 0;
|
portdata->opened = 0;
|
||||||
spin_unlock_irq(&intfdata->susp_lock);
|
spin_unlock_irq(&intfdata->susp_lock);
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
urb = usb_get_from_anchor(&portdata->delayed);
|
||||||
|
if (!urb)
|
||||||
|
break;
|
||||||
|
unbusy_queued_urb(urb, portdata);
|
||||||
|
usb_autopm_put_interface_async(serial->interface);
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < N_IN_URB; i++)
|
for (i = 0; i < N_IN_URB; i++)
|
||||||
usb_kill_urb(portdata->in_urbs[i]);
|
usb_kill_urb(portdata->in_urbs[i]);
|
||||||
for (i = 0; i < N_OUT_URB; i++)
|
for (i = 0; i < N_OUT_URB; i++)
|
||||||
@ -596,18 +618,6 @@ int usb_wwan_suspend(struct usb_serial *serial, pm_message_t message)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(usb_wwan_suspend);
|
EXPORT_SYMBOL(usb_wwan_suspend);
|
||||||
|
|
||||||
static void unbusy_queued_urb(struct urb *urb, struct usb_wwan_port_private *portdata)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < N_OUT_URB; i++) {
|
|
||||||
if (urb == portdata->out_urbs[i]) {
|
|
||||||
clear_bit(i, &portdata->out_busy);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void play_delayed(struct usb_serial_port *port)
|
static void play_delayed(struct usb_serial_port *port)
|
||||||
{
|
{
|
||||||
struct usb_wwan_intf_private *data;
|
struct usb_wwan_intf_private *data;
|
||||||
|
Loading…
Reference in New Issue
Block a user