mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: i2c: rdacm21: Fix missing media_entity_cleanup()
@ 2026-06-13 13:23 Biren Pandya
  0 siblings, 0 replies; only message in thread
From: Biren Pandya @ 2026-06-13 13:23 UTC (permalink / raw)
  To: Jacopo Mondi, Sakari Ailus
  Cc: Mauro Carvalho Chehab, Laurent Pinchart, linux-media,
	linux-kernel, Biren Pandya

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)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-13 13:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-13 13:23 [PATCH] media: i2c: rdacm21: Fix missing media_entity_cleanup() Biren Pandya

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®