Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6f239ba2 authored by Colin Ian King's avatar Colin Ian King Committed by Todd Kjos
Browse files

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

Addresses-Coverity: ("Out-of-bounds read")
Fixes: bc2e15a9a022 ("HID: playstation: initial DualSense USB support.")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Signed-off-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>

Bug: 167947264
Change-Id: I24f4c7f8d48ab8ff1d117d33c7914b8d2e4292f8
(cherry picked from commit 50ab1ffd7c41c5c7759b62fb42d3006b751bb12b)
Signed-off-by: default avatarFarid Chahla <farid.chahla@sony.com>
parent 8e0061c2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -845,7 +845,7 @@ static int dualsense_parse_report(struct ps_device *ps_dev, struct hid_report *r
	input_report_abs(ds->gamepad, ABS_RZ, ds_report->rz);

	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 */
	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);