USB: cdc-acm: fix broken runtime suspend
authorJohan Hovold <jhovold@gmail.com>
Mon, 26 May 2014 17:23:38 +0000 (19:23 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 11 Jul 2014 12:33:41 +0000 (13:33 +0100)
commitab05a2e4be115e07f18152b1569ae8522c4e76a3
tree7087a13784b423aa46027a34de033147da0070a1
parent161427758577d5b5299c0b897730235a1fa950cc
USB: cdc-acm: fix broken runtime suspend

commit 140cb81ac8c625942a1d695875932c615767a526 upstream.

The current ACM runtime-suspend implementation is broken in several
ways:

Firstly, it buffers only the first write request being made while
suspended -- any further writes are silently dropped.

Secondly, writes being dropped also leak write urbs, which are never
reclaimed (until the device is unbound).

Thirdly, even the single buffered write is not cleared at shutdown
(which may happen before the device is resumed), something which can
lead to another urb leak as well as a PM usage-counter leak.

Fix this by implementing a delayed-write queue using urb anchors and
making sure to discard the queue properly at shutdown.

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

Reported-by: Xiao Jin <jin.xiao@intel.com>
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/class/cdc-acm.c
drivers/usb/class/cdc-acm.h