Skip to content

Commit

Permalink
USB: cdc-wdm: updating desc->length must be protected by spin_lock
Browse files Browse the repository at this point in the history
wdm_in_callback() will also touch this field, so we cannot change it without locking

Cc: stable@vger.kernel.org
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Acked-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Bjørn Mork authored and Greg Kroah-Hartman committed Jan 24, 2012
1 parent 1097cce commit c428b70
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/usb/class/cdc-wdm.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,9 @@ static ssize_t wdm_read
for (i = 0; i < desc->length - cntr; i++)
desc->ubuf[i] = desc->ubuf[i + cntr];

spin_lock_irq(&desc->iuspin);
desc->length -= cntr;
spin_unlock_irq(&desc->iuspin);
/* in case we had outstanding data */
if (!desc->length)
clear_bit(WDM_READ, &desc->flags);
Expand Down

0 comments on commit c428b70

Please sign in to comment.