All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] HID: u2fzero: explicitly check for errors
@ 2021-10-18  6:47 Andrej Shadura
  2021-10-18  6:48 ` [PATCH 2/2] HID: u2fzero: properly handle timeouts in usb_submit_urb Andrej Shadura
  2021-10-18  6:56 ` [PATCH 1/2] HID: u2fzero: explicitly check for errors Greg KH
  0 siblings, 2 replies; 5+ messages in thread
From: Andrej Shadura @ 2021-10-18  6:47 UTC (permalink / raw)
  To: Jiří Kosina; +Cc: linux-input, linux-usb, kernel, Benjamin Tissoires

The previous commit fixed handling of incomplete packets but broke error
handling: offsetof returns an unsigned value (size_t), but when compared
against the signed return value, the return value is interpreted as if
it were unsigned, so negative return values are never less than the
offset.

Fixes: 22d65765f211c("HID: u2fzero: ignore incomplete packets without data")
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 d70cd3d7f583..5145d758bea0 100644
--- a/drivers/hid/hid-u2fzero.c
+++ b/drivers/hid/hid-u2fzero.c
@@ -200,7 +200,7 @@ static int u2fzero_rng_read(struct hwrng *rng, void *data,
 	ret = u2fzero_recv(dev, &req, &resp);
 
 	/* ignore errors or packets without data */
-	if (ret < offsetof(struct u2f_hid_msg, init.data))
+	if (ret < 0 || ret < offsetof(struct u2f_hid_msg, init.data))
 		return 0;
 
 	/* only take the minimum amount of data it is safe to take */
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-10-18 12:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-18  6:47 [PATCH 1/2] HID: u2fzero: explicitly check for errors Andrej Shadura
2021-10-18  6:48 ` [PATCH 2/2] HID: u2fzero: properly handle timeouts in usb_submit_urb Andrej Shadura
2021-10-18  6:56 ` [PATCH 1/2] HID: u2fzero: explicitly check for errors Greg KH
2021-10-18 12:06   ` Andrej Shadura
2021-10-18 12:09     ` Andrej Shadura

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.