All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] media: atomisp: ov2722: Return after failed pad initialization
@ 2026-09-15 14:08 Punnay Sharma
  2026-09-15 15:38 ` Dan Carpenter
  2026-09-16  7:36 ` [PATCH v2] media: atomisp: ov2722: Clean up resources on probe failure Punnay Sharma
  0 siblings, 2 replies; 3+ messages in thread
From: Punnay Sharma @ 2026-09-15 14:08 UTC (permalink / raw)
  To: Hans de Goede, Mauro Carvalho Chehab
  Cc: Greg Kroah-Hartman, Sakari Ailus, Andy Shevchenko, linux-media,
	linux-staging, linux-kernel

If media_entity_pads_init() fails, ov2722_probe() calls
ov2722_remove(), which frees the device structure. The probe then
continues into atomisp_register_i2c_module() with a pointer to the
freed subdevice, causing a use-after-free.

Return the original error immediately after cleanup to prevent
registration from accessing the freed device.

Signed-off-by: Punnay Sharma <punnaysharma805@gmail.com>
---
 drivers/staging/media/atomisp/i2c/atomisp-ov2722.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/i2c/atomisp-ov2722.c b/drivers/staging/media/atomisp/i2c/atomisp-ov2722.c
index 2c41c496daa6..0748247ca42c 100644
--- a/drivers/staging/media/atomisp/i2c/atomisp-ov2722.c
+++ b/drivers/staging/media/atomisp/i2c/atomisp-ov2722.c
@@ -979,8 +979,10 @@ static int ov2722_probe(struct i2c_client *client)
 	dev->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	ret = media_entity_pads_init(&dev->sd.entity, 1, &dev->pad);
-	if (ret)
+	if (ret) {
 		ov2722_remove(client);
+		return ret;
+	}
 
 	return atomisp_register_i2c_module(&dev->sd, ovpdev);
 
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-16  7:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-15 14:08 [PATCH v1] media: atomisp: ov2722: Return after failed pad initialization Punnay Sharma
2026-09-15 15:38 ` Dan Carpenter
2026-09-16  7:36 ` [PATCH v2] media: atomisp: ov2722: Clean up resources on probe failure Punnay Sharma

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.