* [PATCH net] mctp i2c: initialise read bytes when no netdev is selected
@ 2026-12-04 2:42 Eric Yun Lin Chiang
0 siblings, 0 replies; only message in thread
From: Eric Yun Lin Chiang @ 2026-12-04 2:42 UTC (permalink / raw)
To: Jeremy Kerr, Matt Johnston
Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, netdev, linux-kernel
Commit 2a14e91b6d76 ("mctp i2c: initialise event handler read bytes")
made reads of an mctp-i2c address return 0xff, but only once a netdev
has been selected. Before that, mctp_i2c_slave_cb() returns early and
leaves *val unset, so the bus driver sends whatever it holds (an
uninitialised stack byte on i2c-aspeed and i2c-npcm7xx).
The slave is registered before any netdev is added. Two in-tree aspeed
device trees set mctp-controller only on mux child busses; there the
netdevs appear only once the mux has probed, and not at all if that
fails.
Set *val to 0xff for read events on that path too.
Fixes: f5b8abf9fc3d ("mctp i2c: MCTP I2C binding driver")
Signed-off-by: Eric Yun Lin Chiang <ericyunlinchiang@gmail.com>
---
I came across this while reading the January read fix. I may be
missing a reason for the no-netdev path to stay as it is; if so, I am
happy to drop this.
Tested: a local KUnit test (UML, KASAN) that calls mctp_i2c_slave_cb()
with no netdev selected and *val preset to 0xa5: without this patch both
read events leave 0xa5, with it both return 0xff; write events are
unchanged. I can send the test if it is useful. Also built for ARM
(aspeed_g5_defconfig + MCTP_TRANSPORT_I2C, W=1 for drivers/net/mctp) and
booted on QEMU ast2600-evb with an mctp-i2c-controller node and no
mctp-controller bus: the device binds to mctp-i2c and no netdev appears,
which is the state this patch covers. Not tested on hardware.
This change was prepared with the help of an AI coding assistant
(Claude); I reviewed it and stand behind it.
drivers/net/mctp/mctp-i2c.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/mctp/mctp-i2c.c b/drivers/net/mctp/mctp-i2c.c
index b02476d33..26e8ea7ff 100644
--- a/drivers/net/mctp/mctp-i2c.c
+++ b/drivers/net/mctp/mctp-i2c.c
@@ -238,8 +238,12 @@ static int mctp_i2c_slave_cb(struct i2c_client *client,
dev_hold(midev->ndev);
spin_unlock_irqrestore(&mcli->sel_lock, flags);
- if (!midev)
+ if (!midev) {
+ if (event == I2C_SLAVE_READ_REQUESTED ||
+ event == I2C_SLAVE_READ_PROCESSED)
+ *val = 0xff;
return 0;
+ }
switch (event) {
case I2C_SLAVE_READ_REQUESTED:
--
2.53.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-04 2:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-04 2:42 [PATCH net] mctp i2c: initialise read bytes when no netdev is selected Eric Yun Lin Chiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®