lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aYL2OAdZTV78Vsy0@zenone.zhora.eu>
Date: Wed, 4 Feb 2026 09:02:19 +0100
From: Andi Shyti <andi.shyti@...nel.org>
To: Felix Gu <ustc.gu@...il.com>
Cc: Chen-Yu Tsai <wens@...nel.org>, 
	Jernej Skrabec <jernej.skrabec@...il.com>, Samuel Holland <samuel@...lland.org>, 
	Maxime Ripard <mripard@...nel.org>, Wolfram Sang <wsa@...nel.org>, 
	Boris Brezillon <bbrezillon@...nel.org>, Arnd Bergmann <arnd@...db.de>, linux-i2c@...r.kernel.org, 
	linux-arm-kernel@...ts.infradead.org, linux-sunxi@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] i2c: sun6i-p2wi: Fix device node reference leak in
 p2wi_probe()

Hi Felix,

On Sun, Feb 01, 2026 at 02:29:00AM +0800, Felix Gu wrote:
> Use the __free(device_node) scoped variable to automatically release
> the device node reference, preventing a device node reference leak.
> 
> Fixes: 3e833490fae5 ("i2c: sunxi: add P2WI (Push/Pull 2 Wire Interface) controller support")
> Signed-off-by: Felix Gu <ustc.gu@...il.com>
> ---
>  drivers/i2c/busses/i2c-sun6i-p2wi.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-sun6i-p2wi.c b/drivers/i2c/busses/i2c-sun6i-p2wi.c
> index fb5280b8cf7f..652b37b57159 100644
> --- a/drivers/i2c/busses/i2c-sun6i-p2wi.c
> +++ b/drivers/i2c/busses/i2c-sun6i-p2wi.c
> @@ -184,7 +184,6 @@ static int p2wi_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
>  	struct device_node *np = dev->of_node;
> -	struct device_node *childnp;
>  	unsigned long parent_clk_freq;
>  	u32 clk_freq = I2C_MAX_STANDARD_MODE_FREQ;
>  	struct p2wi *p2wi;
> @@ -223,7 +222,8 @@ static int p2wi_probe(struct platform_device *pdev)
>  	 * In this case the target_addr is set to -1 and won't be checked when
>  	 * launching a P2WI transfer.
>  	 */
> -	childnp = of_get_next_available_child(np, NULL);
> +	struct device_node *childnp __free(device_node) =
> +		of_get_next_available_child(np, NULL);

A few spontaneous questions here:

- Why are you moving the declaration of childnp in the middle of
  the function?

- Have you run checkpatch.pl before sending the patch?

- Is of_get_next_available_child() allocating the device_node?

- Have you tested the patch?

Thanks,
Andi

>  	if (childnp) {
>  		ret = of_property_read_u32(childnp, "reg", &target_addr);
>  		if (ret) {
> 
> ---
> base-commit: 33a647c659ffa5bdb94abc345c8c86768ff96215
> change-id: 20260201-p2wi-a199cdfe69e0
> 
> Best regards,
> -- 
> Felix Gu <ustc.gu@...il.com>
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ