]> git.karo-electronics.de Git - karo-tx-linux.git/commit
cdc-wdm: Fix more races on the read path
authorBen Hutchings <ben@decadent.org.uk>
Sun, 12 Feb 2012 06:00:41 +0000 (06:00 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 2 Apr 2012 17:31:35 +0000 (10:31 -0700)
commitdd47107e8aff416f9a91ec710c9f3241199adb10
tree2ecb8093fc1c1e7061abe6cb89c93b17ea502e91
parent272ca2f1a3750a39991c73e8ddddf977d5aec846
cdc-wdm: Fix more races on the read path

commit 711c68b3c0f7a924ffbee4aa962d8f62b85188ff upstream.

We must not allow the input buffer length to change while we're
shuffling the buffer contents.  We also mustn't clear the WDM_READ
flag after more data might have arrived.  Therefore move both of these
into the spinlocked region at the bottom of wdm_read().

When reading desc->length without holding the iuspin lock, use
ACCESS_ONCE() to ensure the compiler doesn't re-read it with
inconsistent results.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Tested-by: Bjørn Mork <bjorn@mork.no>
Cc: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/class/cdc-wdm.c