Commit 249a4569 authored by Paul Zimmerman's avatar Paul Zimmerman Committed by Felipe Balbi

usb: dwc3: take lock while modifying flags

dwc3_gadget_ep_set_wedge() and dwc3_gadget_set_selfpowered() were
modifying dwc->flags/dwc->is_selfpowered without taking the lock.
Since those modifications are non-atomic, that could cause other
flags to be corrupted. Fix them both to take the lock.
Signed-off-by: default avatarPaul Zimmerman <paulz@synopsys.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent aee63e3c
...@@ -1196,8 +1196,12 @@ static int dwc3_gadget_ep_set_halt(struct usb_ep *ep, int value) ...@@ -1196,8 +1196,12 @@ static int dwc3_gadget_ep_set_halt(struct usb_ep *ep, int value)
static int dwc3_gadget_ep_set_wedge(struct usb_ep *ep) static int dwc3_gadget_ep_set_wedge(struct usb_ep *ep)
{ {
struct dwc3_ep *dep = to_dwc3_ep(ep); struct dwc3_ep *dep = to_dwc3_ep(ep);
struct dwc3 *dwc = dep->dwc;
unsigned long flags;
spin_lock_irqsave(&dwc->lock, flags);
dep->flags |= DWC3_EP_WEDGE; dep->flags |= DWC3_EP_WEDGE;
spin_unlock_irqrestore(&dwc->lock, flags);
return dwc3_gadget_ep_set_halt(ep, 1); return dwc3_gadget_ep_set_halt(ep, 1);
} }
...@@ -1323,8 +1327,11 @@ static int dwc3_gadget_set_selfpowered(struct usb_gadget *g, ...@@ -1323,8 +1327,11 @@ static int dwc3_gadget_set_selfpowered(struct usb_gadget *g,
int is_selfpowered) int is_selfpowered)
{ {
struct dwc3 *dwc = gadget_to_dwc(g); struct dwc3 *dwc = gadget_to_dwc(g);
unsigned long flags;
spin_lock_irqsave(&dwc->lock, flags);
dwc->is_selfpowered = !!is_selfpowered; dwc->is_selfpowered = !!is_selfpowered;
spin_unlock_irqrestore(&dwc->lock, flags);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment