]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
i2c: fsi: Fix a potential leak in fsi_i2c_probe()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 1 Mar 2026 16:21:01 +0000 (17:21 +0100)
committerAndi Shyti <andi.shyti@kernel.org>
Thu, 19 Mar 2026 22:45:06 +0000 (23:45 +0100)
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>
Cc: <stable@vger.kernel.org> # v5.3+
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/fd805c39f8de51edf303856103d782138a1633c8.1772382022.git.christophe.jaillet@wanadoo.fr
drivers/i2c/busses/i2c-fsi.c

index 82c87e04ac6feefc6d82fb08425654a0994f995c..b2dc5ae1d0e4b817b5820783b0acfbf7ba7b788b 100644 (file)
@@ -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;
                }