mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil+cisco@kernel.org>
To: "Ruoyu Wang" <ruoyuw560@gmail.com>,
	"Kieran Bingham" <kieran.bingham@ideasonboard.com>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Hans Verkuil" <hverkuil@xs4all.nl>,
	"Jacopo Mondi" <jacopo+renesas@jmondi.org>,
	"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>,
	"Laurent Pinchart" <laurent.pinchart@ideasonboard.com>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] media: adv748x: Fix endpoint reference leaks on probe failure
Date: Tue, 8 Sep 2026 11:08:14 +0200	[thread overview]
Message-ID: <507ae44b-1e1c-4ce8-a6d2-69d64d160eaf@kernel.org> (raw)
In-Reply-To: <20260814134106.1387486-1-ruoyuw560@gmail.com>

On 14/08/2026 15:41, Ruoyu Wang wrote:
> adv748x_parse_dt() takes an extra reference for every endpoint saved in
> state->endpoints. If parsing later fails, adv748x_probe() skips
> adv748x_dt_cleanup(), so the saved references remain held. A CSI-2 lane
> parsing error also returns from for_each_endpoint_of_node() without
> dropping the iterator's reference.
> 
> Drop the iterator reference before returning a lane parsing error and
> route all parse failures through the endpoint cleanup path. This balances
> both reference classes while retaining the endpoints for a successful
> probe.
> 
> This issue was found by a static analysis checker and confirmed by
> manual source review.
> 
> Fixes: 6a18865da8e3 ("media: i2c: adv748x: store number of CSI-2 lanes described in device tree")
> Fixes: eccf442ce156 ("media: i2c: adv748x: Support probing a single output")
> Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
> ---
>  drivers/media/i2c/adv748x/adv748x-core.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c
> index 3eb6d5e8f0826..010a4c55b4002 100644
> --- a/drivers/media/i2c/adv748x/adv748x-core.c
> +++ b/drivers/media/i2c/adv748x/adv748x-core.c
> @@ -689,8 +689,10 @@ static int adv748x_parse_dt(struct adv748x_state *state)
>  
>  		/* Store number of CSI-2 lanes used for TXA and TXB. */
>  		ret = adv748x_parse_csi2_lanes(state, ep.port, ep_np);
> -		if (ret)
> +		if (ret) {
> +			of_node_put(ep_np);

Shouldn't this set state->endpoints[ep.port] to NULL as well? Otherwise it will
be put again in adv748x_dt_cleanup(). Or better, wait with setting state->endpoints[ep.port]
until after this check.

Regards,

	Hans

>  			return ret;
> +		}
>  	}
>  
>  	return in_found && out_found ? 0 : -ENODEV;
> @@ -739,7 +741,7 @@ static int adv748x_probe(struct i2c_client *client)
>  	ret = adv748x_parse_dt(state);
>  	if (ret) {
>  		adv_err(state, "Failed to parse device tree");
> -		goto err_free_mutex;
> +		goto err_cleanup_dt;
>  	}
>  
>  	/* Configure IO Regmap region */
> @@ -809,7 +811,6 @@ static int adv748x_probe(struct i2c_client *client)
>  	adv748x_unregister_clients(state);
>  err_cleanup_dt:
>  	adv748x_dt_cleanup(state);
> -err_free_mutex:
>  	mutex_destroy(&state->mutex);
>  
>  	return ret;


      reply	other threads:[~2026-09-08  9:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14 13:41 Ruoyu Wang
2026-09-08  9:08 ` Hans Verkuil [this message]

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=507ae44b-1e1c-4ce8-a6d2-69d64d160eaf@kernel.org \
    --to=hverkuil+cisco@kernel.org \
    --cc=hverkuil@xs4all.nl \
    --cc=jacopo+renesas@jmondi.org \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=ruoyuw560@gmail.com \
    /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®