Skip to content

Commit

Permalink
usb: gadget: mv_u3d_core: fix violation of locking discipline in mv_u…
Browse files Browse the repository at this point in the history
…3d_ep_disable()

mv_u3d_nuke() expects to be calles with ep->u3d->lock held,
because mv_u3d_done() does. But mv_u3d_ep_disable() calls it
without lock that can lead to unpleasant consequences.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Alexey Khoroshilov authored and Felipe Balbi committed Sep 17, 2013
1 parent 272b98c commit 2389df4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/usb/gadget/mv_u3d_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ static int mv_u3d_ep_disable(struct usb_ep *_ep)
struct mv_u3d_ep *ep;
struct mv_u3d_ep_context *ep_context;
u32 epxcr, direction;
unsigned long flags;

if (!_ep)
return -EINVAL;
Expand All @@ -661,7 +662,9 @@ static int mv_u3d_ep_disable(struct usb_ep *_ep)
direction = mv_u3d_ep_dir(ep);

/* nuke all pending requests (does flush) */
spin_lock_irqsave(&u3d->lock, flags);
mv_u3d_nuke(ep, -ESHUTDOWN);
spin_unlock_irqrestore(&u3d->lock, flags);

/* Disable the endpoint for Rx or Tx and reset the endpoint type */
if (direction == MV_U3D_EP_DIR_OUT) {
Expand Down

0 comments on commit 2389df4

Please sign in to comment.