[PATCH] i2c: fsi: put OF node on disabled port skip

Guangshuo Li <[email protected]> Wed, 8 Jul 2026 19:13:44 +0800
Newsgroups org.ozlabs.lists.openbmc,org.kernel.vger.linux-i2c,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
fsi_i2c_find_port_of_node() returns a device node with a reference held
by the caller.

The port skip path added for unavailable nodes also handles the case
where no node was found. That case does not hold a reference. However, if
a port node exists but is disabled, fsi_i2c_find_port_of_node() has
returned a referenced node and the skip path leaks that reference.

Drop the node reference before continuing. of_node_put() is safe for a
NULL node, so the no-node case remains unchanged.

Fixes: 58031a26bf2b ("i2c: fsi: Prevent adding adapters for ports without dts nodes")
Signed-off-by: Guangshuo Li <[email protected]>
---
 drivers/i2c/busses/i2c-fsi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c
index b2dc5ae1d0e4..9ba6b1c59082 100644
--- a/drivers/i2c/busses/i2c-fsi.c
+++ b/drivers/i2c/busses/i2c-fsi.c
@@ -704,8 +704,10 @@ static int fsi_i2c_probe(struct fsi_device *fsi_dev)
 
 	for (port_no = 0; port_no < ports; port_no++) {
 		np = fsi_i2c_find_port_of_node(dev->of_node, port_no);
-		if (!of_device_is_available(np))
+		if (!of_device_is_available(np)) {
+			of_node_put(np);
 			continue;
+		}
 
 		port = kzalloc_obj(*port);
 		if (!port) {
-- 
2.43.0