Skip to content

Commit

Permalink
usb: gadget: r8a66597: fix a loop in set_feature()
Browse files Browse the repository at this point in the history
commit 17956b5 upstream.

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: 96fe53e ("usb: gadget: r8a66597-udc: add support for TEST_MODE")
Cc: stable <stable@vger.kernel.org>
Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Acked-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20210906094221.GA10957@kili
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Dan Carpenter authored and gregkh committed Sep 30, 2021
1 parent 8382972 commit 1fbd7eb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/usb/gadget/udc/r8a66597-udc.c
Expand Up @@ -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,
Expand Down

0 comments on commit 1fbd7eb

Please sign in to comment.