summaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-saitek.c
diff options
context:
space:
mode:
authorAndrej Shadura <andrew.shadura@collabora.co.uk>2021-10-19 17:29:16 +0200
committerJiri Kosina <jkosina@suse.cz>2021-10-27 10:17:08 +0200
commitb7abf78b7a6c4a29a6e0ba0bb883fe44a2f3d693 (patch)
tree4f754a22ece0c12c3ceb9c22e502deabbd51a72c /drivers/hid/hid-saitek.c
parent08b9a61a87bc339a73c584d8924c86ab36d204a7 (diff)
downloadlinux-stable-b7abf78b7a6c4a29a6e0ba0bb883fe44a2f3d693.tar.gz
linux-stable-b7abf78b7a6c4a29a6e0ba0bb883fe44a2f3d693.tar.bz2
linux-stable-b7abf78b7a6c4a29a6e0ba0bb883fe44a2f3d693.zip
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>
Diffstat (limited to 'drivers/hid/hid-saitek.c')
0 files changed, 0 insertions, 0 deletions