diff mbox series

HID: nintendo: Add missing array termination

Message ID 20220712221705.1847793-1-linux@roeck-us.net
State Accepted
Commit ab5f3404b7762b88403fbddbdda6b1b464bd6cbc
Headers show
Series HID: nintendo: Add missing array termination | expand

Commit Message

Guenter Roeck July 12, 2022, 10:17 p.m. UTC
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 <djogorchock@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/hid/hid-nintendo.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Jiri Kosina July 21, 2022, 11:48 a.m. UTC | #1
On Tue, 12 Jul 2022, Dmitry Torokhov wrote:

> On Tue, Jul 12, 2022 at 03:17:05PM -0700, Guenter Roeck wrote:
> > 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 <djogorchock@gmail.com>
> > Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> 
> Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> 
> I'd recommend tagging stable on this one.

I did so and applied, thanks.
diff mbox series

Patch

diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
index 2204de889739..4b1173957c17 100644
--- a/drivers/hid/hid-nintendo.c
+++ b/drivers/hid/hid-nintendo.c
@@ -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)