public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>
To: Myeonghun Pak <mhun512@gmail.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Magnus Damm <magnus.damm@gmail.com>,
	linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	linux-kernel@vger.kernel.org, Ijae Kim <ae878000@gmail.com>
Subject: Re: [PATCH] media: rcar-vin: Clean up notifier on probe failure
Date: Fri, 1 May 2026 11:56:41 +0200	[thread overview]
Message-ID: <20260501095641.GF6708@ragnatech.se> (raw)
In-Reply-To: <20260428125708.93102-1-mhun512@gmail.com>

Hello Myeonghun and Ijae,

Thanks for your patch.

On 2026-04-28 21:57:04 +0900, Myeonghun Pak wrote:
> rvin_group_notifier_init() initializes the group notifier before
> parsing the graph and adding async connections. If parsing fails
> after that point, the function returns without cleaning up the
> notifier, leaving the async connections and their fwnode references
> behind.
> 
> The Gen2/default probe path also fails to drop the group reference
> when rvin_group_notifier_init() returns an error after
> rvin_group_get() succeeded. Unlike a successful probe, .remove() is
> not called for this path, so the probe error path must unwind it
> directly.
> 
> Route notifier-init failures through a common cleanup path, clear
> the cached async connection pointers after cleanup, and make the
> default probe path mirror the CSI-2/ISP group unwind.
> 
> Fixes: 856b49c71ae5 ("media: rcar-vin: Merge all notifiers")
> Co-developed-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Myeonghun Pak <mhun512@gmail.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

> ---
>  .../media/platform/renesas/rcar-vin/rcar-core.c    | 32 ++++++++++++++++++----
>  1 file changed, 26 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-core.c b/drivers/media/platform/renesas/rcar-vin/rcar-core.c
> index c8d564aa1e..8ba8d49c3e 100644
> --- a/drivers/media/platform/renesas/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/renesas/rcar-vin/rcar-core.c
> @@ -318,6 +318,20 @@ static const struct v4l2_async_notifier_operations rvin_group_notify_ops = {
>  	.complete = rvin_group_notify_complete,
>  };
>  
> +static void rvin_group_notifier_cleanup(struct rvin_group *group)
> +{
> +	v4l2_async_nf_cleanup(&group->notifier);
> +
> +	guard(mutex)(&group->lock);
> +
> +	for (unsigned int i = 0; i < RCAR_VIN_NUM; i++)
> +		if (group->vin[i])
> +			group->vin[i]->parallel.asc = NULL;
> +
> +	for (unsigned int i = 0; i < ARRAY_SIZE(group->remotes); i++)
> +		group->remotes[i].asc = NULL;
> +}
> +
>  static int rvin_group_parse_of(struct rvin_dev *vin, unsigned int port,
>  			       unsigned int id)
>  {
> @@ -440,7 +454,7 @@ static int rvin_group_notifier_init(struct rvin_dev *vin, unsigned int port,
>  		/* Parse local subdevice. */
>  		ret = rvin_parallel_parse_of(vin->group->vin[i]);
>  		if (ret)
> -			return ret;
> +			goto err_cleanup;
>  
>  		/* Parse shared subdevices. */
>  		for (id = 0; id < max_id; id++) {
> @@ -449,7 +463,7 @@ static int rvin_group_notifier_init(struct rvin_dev *vin, unsigned int port,
>  
>  			ret = rvin_group_parse_of(vin->group->vin[i], port, id);
>  			if (ret)
> -				return ret;
> +				goto err_cleanup;
>  		}
>  	}
>  
> @@ -460,11 +474,14 @@ static int rvin_group_notifier_init(struct rvin_dev *vin, unsigned int port,
>  	ret = v4l2_async_nf_register(&vin->group->notifier);
>  	if (ret < 0) {
>  		vin_err(vin, "Notifier registration failed\n");
> -		v4l2_async_nf_cleanup(&vin->group->notifier);
> -		return ret;
> +		goto err_cleanup;
>  	}
>  
>  	return 0;
> +
> +err_cleanup:
> +	rvin_group_notifier_cleanup(vin->group);
> +	return ret;
>  }
>  
>  /* -----------------------------------------------------------------------------
> @@ -1228,8 +1245,11 @@ static int rcar_vin_probe(struct platform_device *pdev)
>  		break;
>  	default:
>  		ret = rvin_group_get(vin, rvin_parallel_setup_links, NULL);
> -		if (!ret)
> +		if (!ret) {
>  			ret = rvin_group_notifier_init(vin, 0, 0);
> +			if (ret)
> +				rvin_group_put(vin);
> +		}
>  
>  		if (vin->info->scaler)
>  			vin->scaler = vin->info->scaler;
> @@ -1264,7 +1284,7 @@ static void rcar_vin_remove(struct platform_device *pdev)
>  
>  	if (&vin->v4l2_dev == vin->group->notifier.v4l2_dev) {
>  		v4l2_async_nf_unregister(&vin->group->notifier);
> -		v4l2_async_nf_cleanup(&vin->group->notifier);
> +		rvin_group_notifier_cleanup(vin->group);
>  	}
>  
>  	rvin_group_put(vin);
> -- 
> 2.49.0

-- 
Kind Regards,
Niklas Söderlund

      reply	other threads:[~2026-05-01  9:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-28 12:57 [PATCH] media: rcar-vin: Clean up notifier on probe failure Myeonghun Pak
2026-05-01  9:56 ` Niklas Söderlund [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=20260501095641.GF6708@ragnatech.se \
    --to=niklas.soderlund@ragnatech.se \
    --cc=ae878000@gmail.com \
    --cc=geert+renesas@glider.be \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=mchehab@kernel.org \
    --cc=mhun512@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