mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: ov2659: Fix memleak in ov2659_probe()
@ 2025-06-29 14:49 Zhang Shurong
  2025-06-29 16:45 ` Markus Elfring
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang Shurong @ 2025-06-29 14:49 UTC (permalink / raw)
  To: prabhakar.csengg
  Cc: sakari.ailus, mchehab, linux-media, linux-kernel, Zhang Shurong

ov2659_probe() won't clean all the allocated resources in fail
path, which may causes the memleaks. Add v4l2_ctrl_handler_free() to
prevent memleak.

Fixes: c4c0283ab3cd ("[media] media: i2c: add support for omnivision's ov2659 sensor")
Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
---
 drivers/media/i2c/ov2659.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index 06b7896c3eaf..586b31ba076b 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1469,14 +1469,15 @@ static int ov2659_probe(struct i2c_client *client)
 				     V4L2_CID_TEST_PATTERN,
 				     ARRAY_SIZE(ov2659_test_pattern_menu) - 1,
 				     0, 0, ov2659_test_pattern_menu);
-	ov2659->sd.ctrl_handler = &ov2659->ctrls;
 
 	if (ov2659->ctrls.error) {
 		dev_err(&client->dev, "%s: control initialization error %d\n",
 			__func__, ov2659->ctrls.error);
+		v4l2_ctrl_handler_free(&ov2659->ctrls);
 		return  ov2659->ctrls.error;
 	}
 
+	ov2659->sd.ctrl_handler = &ov2659->ctrls;
 	sd = &ov2659->sd;
 	client->flags |= I2C_CLIENT_SCCB;
 
-- 
2.39.5


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

* Re: [PATCH] media: ov2659: Fix memleak in ov2659_probe()
  2025-06-29 14:49 [PATCH] media: ov2659: Fix memleak in ov2659_probe() Zhang Shurong
@ 2025-06-29 16:45 ` Markus Elfring
  0 siblings, 0 replies; 2+ messages in thread
From: Markus Elfring @ 2025-06-29 16:45 UTC (permalink / raw)
  To: Zhang Shurong, linux-media
  Cc: LKML, Lad Prabhakar, Mauro Carvalho Chehab, Sakari Ailus

> ov2659_probe() won't clean all the allocated resources in fail
> path, which may causes the memleaks. Add v4l2_ctrl_handler_free() to
> prevent memleak.

Will it be nicer to refer to the term “memory leak” for an improved
change description and summary phrase?

Regards,
Markus

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

end of thread, other threads:[~2025-06-29 16:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-29 14:49 [PATCH] media: ov2659: Fix memleak in ov2659_probe() Zhang Shurong
2025-06-29 16:45 ` Markus Elfring

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®