USB: cdc-acm: fix write and suspend race
authorJohan Hovold <jhovold@gmail.com>
Mon, 26 May 2014 17:23:36 +0000 (19:23 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 11 Jul 2014 12:33:41 +0000 (13:33 +0100)
commit3627c07522db92848b8d6414616315028084f5f2
tree09c099c5a4eff5286bf88fa1f00b11b9eab55ff4
parent75a5d8feae868a9b2d84b719fcf4c975c7e02162
USB: cdc-acm: fix write and suspend race

commit 5a345c20c17d87099224a4be12e69e5bd7023dca 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 write_lock after determining the
device is idle but before incrementing the susp_count, thus leaving a
window where a concurrent write() can submit an urb.

Fixes: 11ea859d64b6 ("USB: additional power savings for cdc-acm devices
that support remote wakeup")

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/usb/class/cdc-acm.c