* [PATCH] usb: gadget: r8a66597: fix a loop in set_feature()
@ 2021-09-06 9:42 Dan Carpenter
2021-09-06 9:53 ` Yoshihiro Shimoda
2021-09-07 5:09 ` Felipe Balbi
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2021-09-06 9:42 UTC (permalink / raw)
To: Felipe Balbi, Yoshihiro Shimoda
Cc: Greg Kroah-Hartman, linux-usb, kernel-janitors
This loop is supposed to loop until if reads something other than
CS_IDST or until it times out after 30,000 attempts. But because of
the || vs && bug, it will never time out and instead it will loop a
minimum of 30,000 times.
This bug is quite old but the code is only used in USB_DEVICE_TEST_MODE
so it probably doesn't affect regular usage.
Fixes: 96fe53ef5498 ("usb: gadget: r8a66597-udc: add support for TEST_MODE")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/usb/gadget/udc/r8a66597-udc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c
index 65cae4883454..38e4d6b505a0 100644
--- a/drivers/usb/gadget/udc/r8a66597-udc.c
+++ b/drivers/usb/gadget/udc/r8a66597-udc.c
@@ -1250,7 +1250,7 @@ static void set_feature(struct r8a66597 *r8a66597, struct usb_ctrlrequest *ctrl)
do {
tmp = r8a66597_read(r8a66597, INTSTS0) & CTSQ;
udelay(1);
- } while (tmp != CS_IDST || timeout-- > 0);
+ } while (tmp != CS_IDST && timeout-- > 0);
if (tmp == CS_IDST)
r8a66597_bset(r8a66597,
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* RE: [PATCH] usb: gadget: r8a66597: fix a loop in set_feature()
2021-09-06 9:42 [PATCH] usb: gadget: r8a66597: fix a loop in set_feature() Dan Carpenter
@ 2021-09-06 9:53 ` Yoshihiro Shimoda
2021-09-07 5:09 ` Felipe Balbi
1 sibling, 0 replies; 3+ messages in thread
From: Yoshihiro Shimoda @ 2021-09-06 9:53 UTC (permalink / raw)
To: Dan Carpenter, Felipe Balbi
Cc: Greg Kroah-Hartman, linux-usb@vger.kernel.org,
kernel-janitors@vger.kernel.org
Hi Dan,
> From: Dan Carpenter, Sent: Monday, September 6, 2021 6:42 PM
>
> This loop is supposed to loop until if reads something other than
> CS_IDST or until it times out after 30,000 attempts. But because of
> the || vs && bug, it will never time out and instead it will loop a
> minimum of 30,000 times.
>
> This bug is quite old but the code is only used in USB_DEVICE_TEST_MODE
> so it probably doesn't affect regular usage.
>
> Fixes: 96fe53ef5498 ("usb: gadget: r8a66597-udc: add support for TEST_MODE")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Thank you for the patch!
Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Best regards,
Yoshihiro Shimoda
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] usb: gadget: r8a66597: fix a loop in set_feature()
2021-09-06 9:42 [PATCH] usb: gadget: r8a66597: fix a loop in set_feature() Dan Carpenter
2021-09-06 9:53 ` Yoshihiro Shimoda
@ 2021-09-07 5:09 ` Felipe Balbi
1 sibling, 0 replies; 3+ messages in thread
From: Felipe Balbi @ 2021-09-07 5:09 UTC (permalink / raw)
To: Dan Carpenter
Cc: Yoshihiro Shimoda, Greg Kroah-Hartman, linux-usb, kernel-janitors
Dan Carpenter <dan.carpenter@oracle.com> writes:
> This loop is supposed to loop until if reads something other than
> CS_IDST or until it times out after 30,000 attempts. But because of
> the || vs && bug, it will never time out and instead it will loop a
> minimum of 30,000 times.
>
> This bug is quite old but the code is only used in USB_DEVICE_TEST_MODE
> so it probably doesn't affect regular usage.
>
> Fixes: 96fe53ef5498 ("usb: gadget: r8a66597-udc: add support for TEST_MODE")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Felipe Balbi <balbi@kernel.org>
--
balbi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-07 5:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-06 9:42 [PATCH] usb: gadget: r8a66597: fix a loop in set_feature() Dan Carpenter
2021-09-06 9:53 ` Yoshihiro Shimoda
2021-09-07 5:09 ` Felipe Balbi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).