USB: usb_wwan: fix write and suspend race
authorJohan Hovold <jhovold@gmail.com>
Mon, 26 May 2014 17:23:15 +0000 (19:23 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 11 Jul 2014 12:33:40 +0000 (13:33 +0100)
commit85296fc41103b19ff46fdb7392fb87fd95c91669
tree63bb6731d560bea17c509107e88bcd8045de0081
parent0985cf0a59c203045a80abfaa5647285673b23ba
USB: usb_wwan: fix write and suspend race

commit 170fad9e22df0063eba0701adb966786d7a4ec5a upstream.

Fix race between write() and suspend() which could lead to writes being
dropped (or I/O while suspended) if the device is runtime suspended
while a write request is being processed.

Specifically, suspend() releases the susp_lock after determining the
device is idle but before setting the suspended flag, thus leaving a
window where a concurrent write() can submit an urb.

Fixes: 383cedc3bb43 ("USB: serial: full autosuspend support for the
option driver")

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/usb/serial/usb_wwan.c