Skip to content

Commit 50ab1ff

Browse files
Colin Ian Kingbentiss
authored andcommitted
HID: playstation: fix array size comparison (off-by-one)
The comparison of value with the array size ps_gamepad_hat_mapping appears to be off-by-one. Fix this by using >= rather than > for the size comparison. Addresses-Coverity: ("Out-of-bounds read") Fixes: bc2e15a ("HID: playstation: initial DualSense USB support.") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
1 parent 5fb5255 commit 50ab1ff

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/hid/hid-playstation.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ static int dualsense_parse_report(struct ps_device *ps_dev, struct hid_report *r
845845
input_report_abs(ds->gamepad, ABS_RZ, ds_report->rz);
846846

847847
value = ds_report->buttons[0] & DS_BUTTONS0_HAT_SWITCH;
848-
if (value > ARRAY_SIZE(ps_gamepad_hat_mapping))
848+
if (value >= ARRAY_SIZE(ps_gamepad_hat_mapping))
849849
value = 8; /* center */
850850
input_report_abs(ds->gamepad, ABS_HAT0X, ps_gamepad_hat_mapping[value].x);
851851
input_report_abs(ds->gamepad, ABS_HAT0Y, ps_gamepad_hat_mapping[value].y);

0 commit comments

Comments
 (0)