[PATCH] Input: adafruit-seesaw - check i2c_transfer() return value
From: Siqi Chen
Date: Tue Nov 24 2026 - 00:44:29 EST
i2c_transfer() returns the number of messages transferred or a negative
error code. The seesaw register read helper only checks for negative
errors and therefore treats short transfers as successful.
If only the register-address message is transferred, callers consume
data that was not read from the device. This can result in bogus button
or axis events.
Require both messages to be transferred, preserve negative error codes,
and return -EIO for a short transfer.
Fixes: 52c4e5985a73 ("Input: driver for Adafruit Seesaw Gamepad")
Signed-off-by: Siqi Chen <chensiqi@xxxxxxxxxxxxx>
---
OpenCode was used to identify the issue and draft the code and changelog.
Compile-tested with CONFIG_I2C=y and CONFIG_JOYSTICK_SEESAW=m using:
make O=/tmp/opencode/linux-build-seesaw W=1 \
drivers/input/joystick/adafruit-seesaw.o
No hardware or I2C fault-injection testing was performed.
drivers/input/joystick/adafruit-seesaw.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/input/joystick/adafruit-seesaw.c b/drivers/input/joystick/adafruit-seesaw.c
index 897e14bb61f7..8374381dcc87 100644
--- a/drivers/input/joystick/adafruit-seesaw.c
+++ b/drivers/input/joystick/adafruit-seesaw.c
@@ -107,6 +107,8 @@ static int seesaw_register_read(struct i2c_client *client, u16 reg, void *buf,
ARRAY_SIZE(message_buf));
if (ret < 0)
return ret;
+ if (ret != ARRAY_SIZE(message_buf))
+ return -EIO;
return 0;
}
--
2.20.1