Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: gf2k - skip invalid hat lookup values

gf2k_read() decodes the hat position from a 4-bit field and uses it
directly to index gf2k_hat_to_axis[]. The lookup table only has nine
entries, so malformed packets can read past the end of the fixed table.

Skip hat reporting when the decoded value falls outside the lookup
table instead of forcing it to the neutral position. This keeps the
fix local and avoids reporting a made-up axis state for malformed
packets.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Link: https://patch.msgid.link/20260407120001.1-gf2k-v2-pengpeng@iscas.ac.cn
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Pengpeng Hou and committed by
Dmitry Torokhov
bc561dc8 84e7a17d

+4 -2
+4 -2
drivers/input/joystick/gf2k.c
··· 165 165 166 166 t = GB(40,4,0); 167 167 168 - for (i = 0; i < gf2k_hats[gf2k->id]; i++) 169 - input_report_abs(dev, ABS_HAT0X + i, gf2k_hat_to_axis[t][i]); 168 + if (t < ARRAY_SIZE(gf2k_hat_to_axis)) 169 + for (i = 0; i < gf2k_hats[gf2k->id]; i++) 170 + input_report_abs(dev, ABS_HAT0X + i, 171 + gf2k_hat_to_axis[t][i]); 170 172 171 173 t = GB(44,2,0) | GB(32,8,2) | GB(78,2,10); 172 174