Re: [PATCH 3/3] usb: gadget: udc: renesas_usb3: protect usb3_ep->started in usb3_start_pipen()

2017-07-18 Thread Geert Uytterhoeven
On Tue, Jul 18, 2017 at 2:26 PM, Yoshihiro Shimoda
 wrote:
> This patch fixes an issue that unexpected behavior happens when
> both the interrupt handler and renesas_usb3_ep_enable() are called.
> In this case, since usb3_start_pipen() checked the usb3_ep->started,
> but the flags was not protected. So, this patch protects the flag
> by usb3->lock. Since renesas_usb3_ep_enable() for EP0 will be not called,
> this patch doesn't take care of usb3_start_pipe0().
>
> Signed-off-by: Yoshihiro Shimoda 

Reviewed-by: Geert Uytterhoeven 

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] usb: gadget: udc: renesas_usb3: protect usb3_ep->started in usb3_start_pipen()

2017-07-18 Thread Yoshihiro Shimoda
This patch fixes an issue that unexpected behavior happens when
both the interrupt handler and renesas_usb3_ep_enable() are called.
In this case, since usb3_start_pipen() checked the usb3_ep->started,
but the flags was not protected. So, this patch protects the flag
by usb3->lock. Since renesas_usb3_ep_enable() for EP0 will be not called,
this patch doesn't take care of usb3_start_pipe0().

Signed-off-by: Yoshihiro Shimoda 
---
 drivers/usb/gadget/udc/renesas_usb3.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/udc/renesas_usb3.c 
b/drivers/usb/gadget/udc/renesas_usb3.c
index 1cc5f0d..62dc9c7 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -1415,12 +1415,12 @@ static void usb3_start_pipen(struct renesas_usb3_ep 
*usb3_ep,
int ret = -EAGAIN;
u32 enable_bits = 0;
 
+   spin_lock_irqsave(>lock, flags);
if (usb3_ep->halt || usb3_ep->started)
-   return;
+   goto out;
if (usb3_req != usb3_req_first)
-   return;
+   goto out;
 
-   spin_lock_irqsave(>lock, flags);
if (usb3_pn_change(usb3, usb3_ep->num) < 0)
goto out;
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html