[PATCH] i2c: fsi: Fix a potential leak in fsi_i2c_probe()

Christophe JAILLET posted 1 patch 1 month, 2 weeks ago
drivers/i2c/busses/i2c-fsi.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] i2c: fsi: Fix a potential leak in fsi_i2c_probe()
Posted by Christophe JAILLET 1 month, 2 weeks ago
In the commit in Fixes:, when the code has been updated to use an explicit
for loop, instead of for_each_available_child_of_node(), the assumption
that a reference to a device_node structure would be released at each
iteration has been broken.

Now, an explicit of_node_put() is needed to release the reference.

Fixes: 095561f476ab ("i2c: fsi: Create busses for all ports")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/i2c/busses/i2c-fsi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c
index 82c87e04ac6f..b2dc5ae1d0e4 100644
--- a/drivers/i2c/busses/i2c-fsi.c
+++ b/drivers/i2c/busses/i2c-fsi.c
@@ -729,6 +729,7 @@ static int fsi_i2c_probe(struct fsi_device *fsi_dev)
 		rc = i2c_add_adapter(&port->adapter);
 		if (rc < 0) {
 			dev_err(dev, "Failed to register adapter: %d\n", rc);
+			of_node_put(np);
 			kfree(port);
 			continue;
 		}
-- 
2.53.0
Re: [PATCH] i2c: fsi: Fix a potential leak in fsi_i2c_probe()
Posted by Andi Shyti 3 weeks, 6 days ago
Hi Christophe,

On Sun, Mar 01, 2026 at 05:21:01PM +0100, Christophe JAILLET wrote:
> In the commit in Fixes:, when the code has been updated to use an explicit
> for loop, instead of for_each_available_child_of_node(), the assumption
> that a reference to a device_node structure would be released at each
> iteration has been broken.
> 
> Now, an explicit of_node_put() is needed to release the reference.
> 
> Fixes: 095561f476ab ("i2c: fsi: Create busses for all ports")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

merged to i2c/i2c-host-fixes.

Thanks,
Andi