提交 fe6798d2 编写于 作者: D Dan Carpenter 提交者: Zheng Zengkai

usb: gadget: r8a66597: fix a loop in set_feature()

stable inclusion
from stable-5.10.70
commit 1fbd7eb385c3ecdacb292e32f355e116341e23a8
bugzilla: 182949 https://gitee.com/openeuler/kernel/issues/I4I3GQ

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=1fbd7eb385c3ecdacb292e32f355e116341e23a8

--------------------------------

commit 17956b53 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: 96fe53ef ("usb: gadget: r8a66597-udc: add support for TEST_MODE")
Cc: stable <stable@vger.kernel.org>
Reviewed-by: NYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Acked-by: NFelipe Balbi <balbi@kernel.org>
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20210906094221.GA10957@kiliSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 4cd10114
...@@ -1250,7 +1250,7 @@ static void set_feature(struct r8a66597 *r8a66597, struct usb_ctrlrequest *ctrl) ...@@ -1250,7 +1250,7 @@ static void set_feature(struct r8a66597 *r8a66597, struct usb_ctrlrequest *ctrl)
do { do {
tmp = r8a66597_read(r8a66597, INTSTS0) & CTSQ; tmp = r8a66597_read(r8a66597, INTSTS0) & CTSQ;
udelay(1); udelay(1);
} while (tmp != CS_IDST || timeout-- > 0); } while (tmp != CS_IDST && timeout-- > 0);
if (tmp == CS_IDST) if (tmp == CS_IDST)
r8a66597_bset(r8a66597, r8a66597_bset(r8a66597,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册