]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
USB: cdc-wdm: updating desc->length must be protected by spin_lock
authorBjørn Mork <bjorn@mork.no>
Mon, 16 Jan 2012 11:41:47 +0000 (12:41 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Feb 2012 17:18:59 +0000 (09:18 -0800)
commit c428b70c1e115c5649707a602742e34130d19428 upstream.

wdm_in_callback() will also touch this field, so we cannot change it without locking

Signed-off-by: Bjørn Mork <bjorn@mork.no>
Acked-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/class/cdc-wdm.c

index 2b9ff518b509c3ca45fa7e064aa5be56fbae36ae..bac7478f517afe06b712ded4fadd339507f5542a 100644 (file)
@@ -467,7 +467,9 @@ retry:
        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);