* [PATCH] Input: adafruit-seesaw - check i2c_transfer() return value
@ 2026-11-24 5:43 Siqi Chen
2026-11-24 6:14 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Siqi Chen @ 2026-11-24 5:43 UTC (permalink / raw)
To: Anshul Dalal, Dmitry Torokhov
Cc: Thomas Weißschuh, linux-input, linux-kernel
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@uniontech.com>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Input: adafruit-seesaw - check i2c_transfer() return value
2026-11-24 5:43 [PATCH] Input: adafruit-seesaw - check i2c_transfer() return value Siqi Chen
@ 2026-11-24 6:14 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2026-11-24 6:14 UTC (permalink / raw)
To: Siqi Chen; +Cc: Anshul Dalal, Thomas Weißschuh, linux-input, linux-kernel
On Tue, Nov 24, 2026 at 01:43:44PM +0800, Siqi Chen wrote:
> 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@uniontech.com>
Applied, thank you.
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-24 6:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 5:43 [PATCH] Input: adafruit-seesaw - check i2c_transfer() return value Siqi Chen
2026-11-24 6:14 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox