Linux Media Controller development
 help / color / mirror / Atom feed
From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
To: Biren Pandya <birenpandya@gmail.com>
Cc: "Jacopo Mondi" <jacopo+renesas@jmondi.org>,
	"Kieran Bingham" <kieran.bingham+renesas@ideasonboard.com>,
	"Laurent Pinchart" <laurent.pinchart+renesas@ideasonboard.com>,
	"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Sakari Ailus" <sakari.ailus@linux.intel.com>,
	"open list:RDACM21 Camera Sensor" <linux-media@vger.kernel.org>,
	"open list" <linux-kernel@vger.kernel.org>,
	stable@vger.kernel.org
Subject: Re: [PATCH v2] media: i2c: rdacm21: Fix missing media_entity_cleanup()
Date: Mon, 22 Jun 2026 09:58:57 +0200	[thread overview]
Message-ID: <ajjp7QW_F2Hryuw9@zed> (raw)
In-Reply-To: <20260621060709.54396-2-birenpandya@gmail.com>

Hi Biren

On Sun, Jun 21, 2026 at 11:37:06AM +0530, Biren Pandya wrote:
> If an error occurs after media_entity_pads_init() is called, the media
> entity is left uncleaned, potentially leaking resources or leaving it
> in an invalid state. Similarly, the remove path misses the cleanup.
>
> Add media_entity_cleanup() to both the error path in rdacm21_probe()
> and the rdacm21_remove() function to ensure proper resource release.
>
> Fixes: a59f853b3b4b ("media: i2c: Add driver for RDACM21 camera module")
> Cc: stable@vger.kernel.org

I wouldn't backport this. media_entity_cleanup() does nothing at the
moment and will do nothing on stable kernels as well.

It is anyway worth adding it to the driver in case in future it will
do something.

> Signed-off-by: Biren Pandya <birenpandya@gmail.com>
> ---
>  drivers/media/i2c/rdacm21.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/media/i2c/rdacm21.c b/drivers/media/i2c/rdacm21.c
> index bcab462708c7..41d4242a9b58 100644
> --- a/drivers/media/i2c/rdacm21.c
> +++ b/drivers/media/i2c/rdacm21.c
> @@ -594,6 +594,7 @@ static int rdacm21_probe(struct i2c_client *client)
>
>  error_free_ctrls:
>  	v4l2_ctrl_handler_free(&dev->ctrls);
> +	media_entity_cleanup(&dev->sd.entity);

Don't you think a new label befoer error_free_ctrls: (possibile named
error_entity_cleanup) would be better ?

The code jumps to error_free_ctrls: even before calling
media_entity_pads_init().

Thanks
   j

>  error:
>  	i2c_unregister_device(dev->isp);
>
> @@ -606,6 +607,7 @@ static void rdacm21_remove(struct i2c_client *client)
>
>  	v4l2_async_unregister_subdev(&dev->sd);
>  	v4l2_ctrl_handler_free(&dev->ctrls);
> +	media_entity_cleanup(&dev->sd.entity);
>  	i2c_unregister_device(dev->isp);
>  }
>
> --
> 2.50.1 (Apple Git-155)
>

      reply	other threads:[~2026-06-22  7:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-21  6:07 [PATCH v2] media: i2c: rdacm21: Fix missing media_entity_cleanup() Biren Pandya
2026-06-22  7:58 ` Jacopo Mondi [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=ajjp7QW_F2Hryuw9@zed \
    --to=jacopo.mondi@ideasonboard.com \
    --cc=birenpandya@gmail.com \
    --cc=jacopo+renesas@jmondi.org \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=laurent.pinchart+renesas@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=sakari.ailus@linux.intel.com \
    --cc=stable@vger.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