| From 316ab82fdc75a05811f26fc64c436aa69f863fa2 Mon Sep 17 00:00:00 2001 |
| From: Sasha Levin <sashal@kernel.org> |
| Date: Tue, 13 Jan 2026 17:01:16 +0800 |
| Subject: mctp i2c: initialise event handler read bytes |
| |
| From: Matt Johnston <matt@codeconstruct.com.au> |
| |
| [ Upstream commit 2a14e91b6d76639dac70ea170f4384c1ee3cb48d ] |
| |
| Set a 0xff value for i2c reads of an mctp-i2c device. Otherwise reads |
| will return "val" from the i2c bus driver. For i2c-aspeed and |
| i2c-npcm7xx that is a stack uninitialised u8. |
| |
| Tested with "i2ctransfer -y 1 r10@0x34" where 0x34 is a mctp-i2c |
| instance, now it returns all 0xff. |
| |
| Fixes: f5b8abf9fc3d ("mctp i2c: MCTP I2C binding driver") |
| Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> |
| Link: https://patch.msgid.link/20260113-mctp-read-fix-v1-1-70c4b59c741c@codeconstruct.com.au |
| Signed-off-by: Jakub Kicinski <kuba@kernel.org> |
| Signed-off-by: Sasha Levin <sashal@kernel.org> |
| --- |
| drivers/net/mctp/mctp-i2c.c | 3 +++ |
| 1 file changed, 3 insertions(+) |
| |
| diff --git a/drivers/net/mctp/mctp-i2c.c b/drivers/net/mctp/mctp-i2c.c |
| index ecda1cc36391c..8043b57bdf250 100644 |
| --- a/drivers/net/mctp/mctp-i2c.c |
| +++ b/drivers/net/mctp/mctp-i2c.c |
| @@ -243,7 +243,10 @@ static int mctp_i2c_slave_cb(struct i2c_client *client, |
| |
| switch (event) { |
| case I2C_SLAVE_READ_REQUESTED: |
| + case I2C_SLAVE_READ_PROCESSED: |
| + /* MCTP I2C transport only uses writes */ |
| midev->rx_pos = 0; |
| + *val = 0xff; |
| break; |
| case I2C_SLAVE_WRITE_RECEIVED: |
| if (midev->rx_pos < MCTP_I2C_BUFSZ) { |
| -- |
| 2.51.0 |
| |