Skip to contentSkip to conversation

HID: nintendo: Add missing array termination

PATCH In review Guenter Roeck 3 participants 3 messages Jul 12, 2022 – Jul 21, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: nintendo: Add missing array termination

joycon_dpad_inputs_jc[] is unterminated. This may result in odd warnings such as

input: input_set_capability: invalid code 3077588140 for type 1

or in kernel crashes in nintendo_hid_probe(). Terminate the array to fix the problem.

Fixes 2af16c1f846bd ("HID: nintendo: add nintendo switch controller driver")
Cc Daniel J. Ogorchock <[email protected]>
---
 drivers/hid/hid-nintendo.c | 1 +
 1 file changed, 1 insertion(+)
drivers/hid/hid-nintendo.c +1 -0
index 2204de889739..4b1173957c17 100644
@@ -1586,6 +1586,7 @@ static const unsigned int joycon_button_inputs_r[] = {
 /* We report joy-con d-pad inputs as buttons and pro controller as a hat. */
 static const unsigned int joycon_dpad_inputs_jc[] = {
 	BTN_DPAD_UP, BTN_DPAD_DOWN, BTN_DPAD_LEFT, BTN_DPAD_RIGHT,
+	0 /* 0 signals end of array */
 };
 
 static int joycon_input_create(struct joycon_ctlr *ctlr)
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Guenter Roeck

joycon_dpad_inputs_jc[] is unterminated. This may result in odd warnings such as

input: input_set_capability: invalid code 3077588140 for type 1

or in kernel crashes in nintendo_hid_probe(). Terminate the array to fix the problem.

Fixes 2af16c1f846bd ("HID: nintendo: add nintendo switch controller driver")
Cc Daniel J. Ogorchock <[email protected]>

I'd recommend tagging stable on this one.

Quoted 19 lines
---
 drivers/hid/hid-nintendo.c | 1 +
 1 file changed, 1 insertion(+)
drivers/hid/hid-nintendo.c +1 -0
index 2204de889739..4b1173957c17 100644
@@ -1586,6 +1586,7 @@ static const unsigned int joycon_button_inputs_r[] = {
 /* We report joy-con d-pad inputs as buttons and pro controller as a hat. */
 static const unsigned int joycon_dpad_inputs_jc[] = {
 	BTN_DPAD_UP, BTN_DPAD_DOWN, BTN_DPAD_LEFT, BTN_DPAD_RIGHT,
+	0 /* 0 signals end of array */
 };
 
 static int joycon_input_create(struct joycon_ctlr *ctlr)
Signature · 1 line
2.35.1

Thanks.

Signature · 1 line
Dmitry
maintainer
#2 lore raw
Quoted 9 lines · Dmitry Torokhov
Quoted 8 lines · Guenter Roeck

joycon_dpad_inputs_jc[] is unterminated. This may result in odd warnings such as

input: input_set_capability: invalid code 3077588140 for type 1

or in kernel crashes in nintendo_hid_probe(). Terminate the array to fix the problem.

Quoted 7 lines
Quoted 3 lines
Fixes 2af16c1f846bd ("HID: nintendo: add nintendo switch controller driver")
Cc Daniel J. Ogorchock <[email protected]>

I'd recommend tagging stable on this one.

I did so and applied, thanks.

Signature · 2 lines
Jiri Kosina
SUSE Labs