mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 22:21:42 +00:00
HID: steelseries: Fix signedness bug in steelseries_headset_arctis_1_fetch_battery()
The hid_hw_raw_request() function returns negative error codes or the
number bytes transferred. The problem is that when it returns negative
error codes and we check if "ret < sizeof(arctis_1_battery_request)",
then the negative values are type promoted from int to high unsigned long
values and treated as success.
This was detected using Smatch:
drivers/hid/hid-steelseries.c:393 steelseries_headset_arctis_1_fetch_battery()
warn: error code type promoted to positive: 'ret'
Fixes: a0c76896c3
("HID: steelseries: Add support for Arctis 1 XBox")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Bastien Nocera <hadess@hadess.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
This commit is contained in:
parent
e1cd4004cd
commit
6c667ef6e2
@ -390,7 +390,7 @@ static int steelseries_headset_arctis_1_fetch_battery(struct hid_device *hdev)
|
|||||||
ret = hid_hw_raw_request(hdev, arctis_1_battery_request[0],
|
ret = hid_hw_raw_request(hdev, arctis_1_battery_request[0],
|
||||||
write_buf, sizeof(arctis_1_battery_request),
|
write_buf, sizeof(arctis_1_battery_request),
|
||||||
HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);
|
HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);
|
||||||
if (ret < sizeof(arctis_1_battery_request)) {
|
if (ret < (int)sizeof(arctis_1_battery_request)) {
|
||||||
hid_err(hdev, "hid_hw_raw_request() failed with %d\n", ret);
|
hid_err(hdev, "hid_hw_raw_request() failed with %d\n", ret);
|
||||||
ret = -ENODATA;
|
ret = -ENODATA;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user