UPSTREAM: 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 the >= rather than > for the
size comparison.

Bug: 167947264
CRs-fixed: 2971837
Change-Id: I24f4c7f8d48ab8ff1d117d33c7914b8d2e4292f8
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Farid Chahla <farid.chahla@sony.com>
Signed-off-by: Siarhei Vishniakou <svv@google.com>
Git-repo: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
Git-commit: 50ab1ffd7c41c5c7759b62fb42d3006b751bb12b
Signed-off-by: Kishor Krishna Bhat <kishkris@codeaurora.org>
This commit is contained in:
Colin Ian King
2021-07-13 14:58:34 +05:30
committed by Kishor Krishna Bhat
parent f0e3e17c94
commit 7c1277fcf2

View File

@@ -848,7 +848,7 @@ static int dualsense_parse_report(struct ps_device *ps_dev,
input_report_abs(ds->gamepad, ABS_RZ, ds_report->rz); input_report_abs(ds->gamepad, ABS_RZ, ds_report->rz);
value = ds_report->buttons[0] & DS_BUTTONS0_HAT_SWITCH; value = ds_report->buttons[0] & DS_BUTTONS0_HAT_SWITCH;
if (value > ARRAY_SIZE(ps_gamepad_hat_mapping)) if (value >= ARRAY_SIZE(ps_gamepad_hat_mapping))
value = 8; /* center */ value = 8; /* center */
input_report_abs(ds->gamepad, ABS_HAT0X, ps_gamepad_hat_mapping[value].x); input_report_abs(ds->gamepad, ABS_HAT0X, ps_gamepad_hat_mapping[value].x);
input_report_abs(ds->gamepad, ABS_HAT0Y, ps_gamepad_hat_mapping[value].y); input_report_abs(ds->gamepad, ABS_HAT0Y, ps_gamepad_hat_mapping[value].y);