Skip to content

Commit

Permalink
Merge "USB: f_fs: Fix disconnect check during ongoing IO"
Browse files Browse the repository at this point in the history
  • Loading branch information
Linux Build Service Account authored and Gerrit - the friendly Code Review server committed Oct 27, 2014
2 parents 5489edf + 81cb997 commit a37b1d3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions drivers/usb/gadget/f_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -876,13 +876,21 @@ static ssize_t ffs_epfile_io(struct file *file,
ret = -EIO;
} else if (unlikely(wait_for_completion_interruptible(&done))) {
spin_lock_irq(&epfile->ffs->eps_lock);
if (ep->ep)
/*
* While we were acquiring lock endpoint got disabled
* (disconnect) or changed (composition switch) ?
*/
if (epfile->ep == ep)
usb_ep_dequeue(ep->ep, req);
spin_unlock_irq(&epfile->ffs->eps_lock);
ret = -EINTR;
} else {
spin_lock_irq(&epfile->ffs->eps_lock);
if (ep->ep)
/*
* While we were acquiring lock endpoint got disabled
* (disconnect) or changed (composition switch) ?
*/
if (epfile->ep == ep)
ret = ep->status;
else
ret = -ENODEV;
Expand Down Expand Up @@ -1561,6 +1569,7 @@ static void ffs_func_free(struct ffs_function *func)
if (ep->ep && ep->req)
usb_ep_free_request(ep->ep, ep->req);
ep->req = NULL;
ep->ep = NULL;
++ep;
} while (--count);
spin_unlock_irqrestore(&func->ffs->eps_lock, flags);
Expand Down

0 comments on commit a37b1d3

Please sign in to comment.