summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJian Zhang <zhangjian.3032@bytedance.com>2026-01-08 18:18:29 +0800
committerSasha Levin <sashal@kernel.org>2026-03-04 07:19:39 -0500
commit40089ce7dfe3c4db9b239e89b172ee302c5f6a4f (patch)
treea51aada8d98bcde6d85daf61eda5f580d14c9112
parent47a81f6aa8aa2cc62af2fad1a21ee8da3d177f5f (diff)
net: mctp-i2c: fix duplicate reception of old data
[ Upstream commit ae4744e173fadd092c43eda4ca92dcb74645225a ] The MCTP I2C slave callback did not handle I2C_SLAVE_READ_REQUESTED events. As a result, i2c read event will trigger repeated reception of old data, reset rx_pos when a read request is received. Signed-off-by: Jian Zhang <zhangjian.3032@bytedance.com> Link: https://patch.msgid.link/20260108101829.1140448-1-zhangjian.3032@bytedance.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Stable-dep-of: 2a14e91b6d76 ("mctp i2c: initialise event handler read bytes") Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/net/mctp/mctp-i2c.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/net/mctp/mctp-i2c.c b/drivers/net/mctp/mctp-i2c.c
index 17619d011689..1d0c51684279 100644
--- a/drivers/net/mctp/mctp-i2c.c
+++ b/drivers/net/mctp/mctp-i2c.c
@@ -243,6 +243,9 @@ static int mctp_i2c_slave_cb(struct i2c_client *client,
return 0;
switch (event) {
+ case I2C_SLAVE_READ_REQUESTED:
+ midev->rx_pos = 0;
+ break;
case I2C_SLAVE_WRITE_RECEIVED:
if (midev->rx_pos < MCTP_I2C_BUFSZ) {
midev->rx_buffer[midev->rx_pos] = *val;
@@ -280,6 +283,9 @@ static int mctp_i2c_recv(struct mctp_i2c_dev *midev)
size_t recvlen;
int status;
+ if (midev->rx_pos == 0)
+ return 0;
+
/* + 1 for the PEC */
if (midev->rx_pos < MCTP_I2C_MINLEN + 1) {
ndev->stats.rx_length_errors++;