Skip to content

Commit 6c667ef

Browse files
Dan CarpenterJiri Kosina
authored andcommitted
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: a0c7689 ("HID: steelseries: Add support for Arctis 1 XBox") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Bastien Nocera <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent e1cd400 commit 6c667ef

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/hid/hid-steelseries.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ static int steelseries_headset_arctis_1_fetch_battery(struct hid_device *hdev)
390390
ret = hid_hw_raw_request(hdev, arctis_1_battery_request[0],
391391
write_buf, sizeof(arctis_1_battery_request),
392392
HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);
393-
if (ret < sizeof(arctis_1_battery_request)) {
393+
if (ret < (int)sizeof(arctis_1_battery_request)) {
394394
hid_err(hdev, "hid_hw_raw_request() failed with %d\n", ret);
395395
ret = -ENODATA;
396396
}

0 commit comments

Comments
 (0)