[PATCH] i2c: mux: Fix the crash when the i2c-arbitrator node is present

Venkatesh Yadav Abbarapu venkatesh.abbarapu at amd.com
Wed May 28 05:12:55 CEST 2025


Observing the crash when we add the i2c-arbitrator node in the device
tree as per the DT bindings. The issue is with the child node of
i2c-arbitrator at 72 i.e., i2c at f1950000->i2c-arbitrator at 72->i2c-arb, as the
arbitrator uses the uclass of mux(UCLASS_I2C_MUX) and the mux uclass driver
checks for the "reg" property using the i2c_mux_child_post_bind() function,
if it won't find the "reg" property it will return -EINVAL which is leading
to the crash.
So, add the logic to check whether the  child node has the "reg" property,
if the "reg" property exists then read the "reg" and update the channel.

https://www.kernel.org/doc/Documentation/devicetree/bindings/i2c/i2c-arb.txt

Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu at amd.com>
---
 drivers/i2c/muxes/i2c-mux-uclass.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/muxes/i2c-mux-uclass.c b/drivers/i2c/muxes/i2c-mux-uclass.c
index d1999d21feb..b18999c1fe3 100644
--- a/drivers/i2c/muxes/i2c-mux-uclass.c
+++ b/drivers/i2c/muxes/i2c-mux-uclass.c
@@ -40,11 +40,14 @@ static int i2c_mux_child_post_bind(struct udevice *dev)
 	struct i2c_mux_bus *plat = dev_get_parent_plat(dev);
 	int channel;
 
-	channel = dev_read_u32_default(dev, "reg", -1);
-	if (channel < 0)
-		return -EINVAL;
-	plat->channel = channel;
+	ofnode node = dev_ofnode(dev);
 
+	if (ofnode_has_property(node, "reg")) {
+		channel = dev_read_u32_default(dev, "reg", -1);
+		if (channel < 0)
+			return -EINVAL;
+		plat->channel = channel;
+	}
 	return 0;
 }
 
-- 
2.34.1



More information about the U-Boot mailing list