mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Biren Pandya <birenpandya@gmail.com>
To: Jacopo Mondi <jacopo+renesas@jmondi.org>,
	Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	Biren Pandya <birenpandya@gmail.com>
Subject: [PATCH] media: i2c: rdacm21: Fix missing media_entity_cleanup()
Date: Sat, 13 Jun 2026 18:53:06 +0530	[thread overview]
Message-ID: <20260613132306.69394-1-birenpandya@gmail.com> (raw)

If v4l2_async_register_subdev() fails, or if rdacm21_probe() hits any
other error 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")
---
 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 bcab462..26088eb 100644
--- a/drivers/media/i2c/rdacm21.c
+++ b/drivers/media/i2c/rdacm21.c
@@ -595,6 +595,7 @@ static int rdacm21_probe(struct i2c_client *client)
 error_free_ctrls:
 	v4l2_ctrl_handler_free(&dev->ctrls);
 error:
+	media_entity_cleanup(&dev->sd.entity);
 	i2c_unregister_device(dev->isp);
 
 	return ret;
@@ -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-13 13:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260613132306.69394-1-birenpandya@gmail.com \
    --to=birenpandya@gmail.com \
    --cc=jacopo+renesas@jmondi.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab+huawei@kernel.org \
    --cc=sakari.ailus@linux.intel.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®