Skip to content

Commit

Permalink
HID: u2fzero: properly handle timeouts in usb_submit_urb
Browse files Browse the repository at this point in the history
[ Upstream commit 43775e6 ]

The wait_for_completion_timeout function returns 0 if timed out or a
positive value if completed. Hence, "less than zero" comparison always
misses timeouts and doesn't kill the URB as it should, leading to
re-sending it while it is active.

Fixes: 42337b9 ("HID: add driver for U2F Zero built-in LED and RNG")
Signed-off-by: Andrej Shadura <andrew.shadura@collabora.co.uk>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
andrewshadura authored and gregkh committed Nov 18, 2021
1 parent e2f0bff commit 4310970
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/hid/hid-u2fzero.c
Expand Up @@ -132,7 +132,7 @@ static int u2fzero_recv(struct u2fzero_device *dev,

ret = (wait_for_completion_timeout(
&ctx.done, msecs_to_jiffies(USB_CTRL_SET_TIMEOUT)));
if (ret < 0) {
if (ret == 0) {
usb_kill_urb(dev->urb);
hid_err(hdev, "urb submission timed out");
} else {
Expand Down

0 comments on commit 4310970

Please sign in to comment.