[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <33bf15be-f99a-40c1-a97c-a51ca8fa4c9e@wanadoo.fr>
Date: Sun, 6 Apr 2025 20:06:29 +0200
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: Sunny Patel <nueralspacetech@...il.com>,
Wolfram Sang <wsa+renesas@...g-engineering.com>
Cc: linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] i2c: Fix reference leak in of_i2c_register_devices
Le 06/04/2025 à 15:48, Sunny Patel a écrit :
> Fix a potential reference leak in of_i2c_register_devices where the
> reference to the node is not released if device registration fails.
> This ensures proper reference management and avoids memory leaks.
There is no early exit path in the for_each_available_child_of_node()
block, so of_node_put((node) is called for all the nodes that are iterated.
Can you elaborate and explain how the reference leak can occur?
CJ
>
> Signed-off-by: Sunny Patel <nueralspacetech@...il.com>
> ---
> drivers/i2c/i2c-core-of.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c
> index 02feee6c9ba9..7c50905de8f1 100644
> --- a/drivers/i2c/i2c-core-of.c
> +++ b/drivers/i2c/i2c-core-of.c
> @@ -107,6 +107,7 @@ void of_i2c_register_devices(struct i2c_adapter *adap)
> "Failed to create I2C device for %pOF\n",
> node);
> of_node_clear_flag(node, OF_POPULATED);
> + of_node_put(node);
> }
> }
>
Powered by blists - more mailing lists