mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andi Shyti <andi.shyti@kernel.org>
To: Felix Gu <ustc.gu@gmail.com>
Cc: Chen-Yu Tsai <wens@kernel.org>,
	 Jernej Skrabec <jernej.skrabec@gmail.com>,
	Samuel Holland <samuel@sholland.org>,
	 Maxime Ripard <mripard@kernel.org>,
	Wolfram Sang <wsa@kernel.org>,
	 Boris Brezillon <bbrezillon@kernel.org>,
	Arnd Bergmann <arnd@arndb.de>,
	linux-i2c@vger.kernel.org,  linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] i2c: sun6i-p2wi: Fix device node reference leak in p2wi_probe()
Date: Wed, 4 Feb 2026 09:02:19 +0100	[thread overview]
Message-ID: <aYL2OAdZTV78Vsy0@zenone.zhora.eu> (raw)
In-Reply-To: <20260201-p2wi-v1-1-e0ec9cda82b3@gmail.com>

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@gmail.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@gmail.com>
> 

  reply	other threads:[~2026-02-04  8:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-31 18:29 Felix Gu
2026-02-04  8:02 ` Andi Shyti [this message]
2026-05-01 20:30 ` [PATCH v2] i2c: sun6i-p2wi: fix of_node reference leak in probe Shitalkumar Gandhi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aYL2OAdZTV78Vsy0@zenone.zhora.eu \
    --to=andi.shyti@kernel.org \
    --cc=arnd@arndb.de \
    --cc=bbrezillon@kernel.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=mripard@kernel.org \
    --cc=samuel@sholland.org \
    --cc=ustc.gu@gmail.com \
    --cc=wens@kernel.org \
    --cc=wsa@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®