[PATCH 05/10] Input: stinger - zero-initialise driver state in stinger_connect()

From: Lee Jones

Date: Mon Nov 23 2026 - 13:32:49 EST


stinger_connect() allocates struct stinger with kmalloc_obj() without
initialising the signed packet index stinger->idx.

When serial bytes arrive in stinger_interrupt(), negative values of
stinger->idx pass the stinger->idx < STINGER_MAX_LENGTH check and cause
stinger->data[stinger->idx++] to write before the start of stinger->data
on the heap, corrupting stinger->dev or adjacent slab memory. Initial
values of 4 or greater never match the stinger->idx == 4 reset check and
permanently wedge packet assembly.

Allocate struct stinger with kzalloc_obj() so stinger->idx and the
packet buffer start zeroed.

Fixes: 17dd3f0f7aa7 ("[PATCH] drivers/input/joystick: convert to dynamic input_dev allocation")
Closes: https://sashiko.dev/#/bug/linux-bad333c0-5b62-4ca5-ad93-204400bcba3a
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/input/joystick/stinger.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/joystick/stinger.c b/drivers/input/joystick/stinger.c
index 011f9b137dca..021216f811c0 100644
--- a/drivers/input/joystick/stinger.c
+++ b/drivers/input/joystick/stinger.c
@@ -118,7 +118,7 @@ static int stinger_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev;
int err = -ENOMEM;

- stinger = kmalloc_obj(*stinger);
+ stinger = kzalloc_obj(*stinger);
input_dev = input_allocate_device();
if (!stinger || !input_dev)
goto fail1;
--
2.56.1.750.gf70dc682cf-goog