mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
USB: gadgetfs: fix copy_to_user while holding spinlock
The gadgetfs driver as a long-outstanding FIXME, regarding a call of copy_to_user() made while holding a spinlock. This patch fixes the issue by dropping the spinlock and using the dev->udc_usage mechanism introduced by another recent patch to guard against status changes while the lock isn't held. Signed-off-by: Alan Stern <[email protected]> Reported-by: Andrey Konovalov <[email protected]> CC: <[email protected]> Acked-by: Felipe Balbi <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
parent
786de92b3c
commit
6e76c01e71
1 changed files with 4 additions and 1 deletions
|
|
@ -983,11 +983,14 @@ ep0_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr)
|
|||
retval = -EIO;
|
||||
else {
|
||||
len = min (len, (size_t)dev->req->actual);
|
||||
// FIXME don't call this with the spinlock held ...
|
||||
++dev->udc_usage;
|
||||
spin_unlock_irq(&dev->lock);
|
||||
if (copy_to_user (buf, dev->req->buf, len))
|
||||
retval = -EFAULT;
|
||||
else
|
||||
retval = len;
|
||||
spin_lock_irq(&dev->lock);
|
||||
--dev->udc_usage;
|
||||
clean_req (dev->gadget->ep0, dev->req);
|
||||
/* NOTE userspace can't yet choose to stall */
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue