]> 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 16:26:59 +0000 (09:26 -0700)
commit3b804c7c32ed23181025a5184cae7e2d5a237f48
tree07c9a9c9f7c0ea734dae8f2b46bae924f69d9788
parenta4b9552b4fa34648a5017901ed8042214a9dfc03
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