Linux Media Controller development
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Biren Pandya <birenpandya@gmail.com>
Cc: linux-media@vger.kernel.org,
	Dave Stevenson <dave.stevenson@raspberrypi.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Manivannan Sadhasivam <mani@kernel.org>,
	Steve Longerbeam <slongerbeam@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] media: i2c: ov5640: Drop manual fwnode_handle_put() via scope-based cleanup
Date: Wed, 8 Jul 2026 11:49:07 +0300	[thread overview]
Message-ID: <ak4PAzSTC4yoV3Zy@kekkonen.localdomain> (raw)
In-Reply-To: <20260615223055.39953-2-birenpandya@gmail.com>

Hi Biren,

On Tue, Jun 16, 2026 at 04:00:53AM +0530, Biren Pandya wrote:
> Utilize the __free(fwnode_handle) scoped guard macro from <linux/cleanup.h> to automate the lifecycle management of the endpoint fwnode in ov5640_probe().
> 
> This eliminates the need for the manual fwnode_handle_put() call, preventing potential memory leaks in error paths and simplifying the probe routine.

Please wrap to 75 characters per line.

> 
> Signed-off-by: Biren Pandya <birenpandya@gmail.com>
> ---
>  drivers/media/i2c/ov5640.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
> index ce6b0724afa1..7795f2de0f75 100644
> --- a/drivers/media/i2c/ov5640.c
> +++ b/drivers/media/i2c/ov5640.c
> @@ -4,6 +4,7 @@
>   * Copyright (C) 2014-2017 Mentor Graphics Inc.
>   */
>  
> +#include <linux/cleanup.h>
>  #include <linux/clk.h>
>  #include <linux/clk-provider.h>
>  #include <linux/clkdev.h>
> @@ -3845,7 +3846,6 @@ static int ov5640_check_chip_id(struct ov5640_dev *sensor)
>  static int ov5640_probe(struct i2c_client *client)
>  {
>  	struct device *dev = &client->dev;
> -	struct fwnode_handle *endpoint;
>  	struct ov5640_dev *sensor;
>  	int ret;
>  
> @@ -3870,15 +3870,14 @@ static int ov5640_probe(struct i2c_client *client)
>  
>  	sensor->ae_target = 52;
>  
> -	endpoint = fwnode_graph_get_next_endpoint(dev_fwnode(&client->dev),
> -						  NULL);
> +	struct fwnode_handle *endpoint __free(fwnode_handle) =
> +		fwnode_graph_get_next_endpoint(dev_fwnode(&client->dev), NULL);

I'm fine with using __free() here.

>  	if (!endpoint) {
>  		dev_err(dev, "endpoint node not found\n");
>  		return -EINVAL;
>  	}

This check can be removed in the same patch. It's now redundant as
v4l2_fwnode_endpoint_parse() also does it.

>  
>  	ret = v4l2_fwnode_endpoint_parse(endpoint, &sensor->ep);
> -	fwnode_handle_put(endpoint);
>  	if (ret) {
>  		dev_err(dev, "Could not parse endpoint\n");
>  		return ret;

-- 
Regards,

Sakari Ailus

  reply	other threads:[~2026-07-08  8:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-15 22:30 [PATCH 0/3] media: i2c: Adopt scope-based fwnode_handle_put Biren Pandya
2026-06-15 22:30 ` [PATCH 1/3] media: i2c: ov5640: Drop manual fwnode_handle_put() via scope-based cleanup Biren Pandya
2026-07-08  8:49   ` Sakari Ailus [this message]
2026-06-15 22:30 ` [PATCH 2/3] media: i2c: imx290: " Biren Pandya
2026-06-15 22:30 ` [PATCH 3/3] media: i2c: imx219: " Biren Pandya
     [not found] ` <20260708134403.45935-5-birenpandya@gmail.com>
2026-07-08 13:44   ` [PATCH v3 1/3] media: i2c: ov5640: use scoped fwnode_handle endpoint cleanup Biren Pandya
2026-07-08 13:44   ` [PATCH v3 2/3] media: i2c: imx290: Drop manual fwnode_handle_put() via scope-based cleanup Biren Pandya
2026-07-08 13:44   ` [PATCH v3 3/3] media: i2c: imx219: " Biren Pandya

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=ak4PAzSTC4yoV3Zy@kekkonen.localdomain \
    --to=sakari.ailus@linux.intel.com \
    --cc=birenpandya@gmail.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=mchehab@kernel.org \
    --cc=slongerbeam@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