Message ID | 20200921112052.27943-6-oneukum@suse.com |
---|---|
State | New |
Headers | show |
Series | [RFC,1/8] CDC-WDM: fix hangs in flush() | expand |
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c index 40661b9f6775..89929f6438e3 100644 --- a/drivers/usb/class/cdc-wdm.c +++ b/drivers/usb/class/cdc-wdm.c @@ -614,8 +614,11 @@ static int wdm_flush(struct file *file, fl_owner_t id) return -EIO; if (rv < 0) return -EINTR; + + spin_lock_irq(&desc->iuspin); rv = desc->werr; desc->werr = 0; + spin_unlock_irq(&desc->iuspin); return usb_translate_errors(rv); }
In case a race was lost and multiple fds used, an error could be reported multiple times. To fix this a spinlock must be taken. Signed-off-by: Oliver Neukum <oneukum@suse.com> --- drivers/usb/class/cdc-wdm.c | 3 +++ 1 file changed, 3 insertions(+)