All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrej Shadura <andrew.shadura@collabora.co.uk>
To: "Jiří Kosina" <jikos@kernel.org>
Cc: linux-input@vger.kernel.org, linux-usb@vger.kernel.org,
	kernel@collabora.com,
	Benjamin Tissoires <benjamin.tissoires@gmail.com>
Subject: [PATCH 2/2] HID: u2fzero: properly handle timeouts in usb_submit_urb
Date: Mon, 18 Oct 2021 08:48:00 +0200	[thread overview]
Message-ID: <20211018064800.15173-2-andrew.shadura@collabora.co.uk> (raw)
In-Reply-To: <20211018064800.15173-1-andrew.shadura@collabora.co.uk>

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: 42337b9d4d958("HID: add driver for U2F Zero built-in LED and RNG")
Signed-off-by: Andrej Shadura <andrew.shadura@collabora.co.uk>
---
 drivers/hid/hid-u2fzero.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-u2fzero.c b/drivers/hid/hid-u2fzero.c
index 5145d758bea0..562da98cfb82 100644
--- a/drivers/hid/hid-u2fzero.c
+++ b/drivers/hid/hid-u2fzero.c
@@ -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 {
-- 
2.33.0


  reply	other threads:[~2021-10-18  6:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-18  6:47 [PATCH 1/2] HID: u2fzero: explicitly check for errors Andrej Shadura
2021-10-18  6:48 ` Andrej Shadura [this message]
2021-10-18  6:56 ` Greg KH
2021-10-18 12:06   ` Andrej Shadura
2021-10-18 12:09     ` Andrej Shadura

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211018064800.15173-2-andrew.shadura@collabora.co.uk \
    --to=andrew.shadura@collabora.co.uk \
    --cc=benjamin.tissoires@gmail.com \
    --cc=jikos@kernel.org \
    --cc=kernel@collabora.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.