Home
last modified time | relevance | path

Searched hist:b7abf78b (Results 1 – 1 of 1) sorted by relevance

/openbmc/linux/drivers/hid/
H A Dhid-u2fzero.cb7abf78b Tue Oct 19 10:29:16 CDT 2021 Andrej Shadura <andrew.shadura@collabora.co.uk> HID: u2fzero: clarify error check and length calculations

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.

To make the code easier to read, calculate the minimal packet length
once and separately, and assign it to a signed int variable to eliminate
unsigned math and the need for type casts. It then becomes immediately
obvious how the actual data length is calculated and why the return
value cannot be less than the minimal length.

Fixes: 22d65765f211 ("HID: u2fzero: ignore incomplete packets without data")
Fixes: 42337b9d4d95 ("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>