]> git.baikalelectronics.ru Git - kernel.git/commit
usb: cdc-wdm: resp_count can be 0 even if WDM_READ is set
authorBjørn Mork <bjorn@mork.no>
Sun, 12 Jan 2014 20:48:53 +0000 (21:48 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 13 Jan 2014 04:13:28 +0000 (20:13 -0800)
commite36c79f61dacd41fa23104d3ab15fd8ea1095007
treef25186b2329acd71e206d510c01be31ece23aae9
parentb96e4386107442d9ff1c0dffecd8470c2dbec32c
usb: cdc-wdm: resp_count can be 0 even if WDM_READ is set

Do not decrement resp_count if it's already 0.

We set resp_count to 0 when the device is closed.  The next open and
read will try to clear the WDM_READ flag if there was leftover data
in the read buffer. This fix is necessary to prevent resubmitting
the read URB in a tight loop because resp_count becomes negative.

The bug can easily be triggered from userspace by not reading all
data in the read buffer, and then closing and reopening the chardev.

Fixes: 0b55a15bc27a ("usb: cdc-wdm: avoid hanging on zero length reads")
Cc: <stable@vger.kernel.org> # 3.13
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/class/cdc-wdm.c