mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: hi846: Fix memleak in hi846_init_controls()
@ 2023-03-24 17:24 Wei Chen
  2023-03-26  8:50 ` Martin Kepplinger
  0 siblings, 1 reply; 3+ messages in thread
From: Wei Chen @ 2023-03-24 17:24 UTC (permalink / raw)
  To: martink; +Cc: mchehab, linux-media, linux-kernel, Wei Chen

hi846_init_controls doesn't clean the allocated ctrl_hdlr
in case there is a failure, which causes memleak. Add
v4l2_ctrl_handler_free to free the resource properly.

Signed-off-by: Wei Chen <harperchen1110@gmail.com>
---
 drivers/media/i2c/hi846.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/i2c/hi846.c b/drivers/media/i2c/hi846.c
index 7c61873b7198..c45a6511d2c1 100644
--- a/drivers/media/i2c/hi846.c
+++ b/drivers/media/i2c/hi846.c
@@ -1472,6 +1472,7 @@ static int hi846_init_controls(struct hi846 *hi846)
 	if (ctrl_hdlr->error) {
 		dev_err(&client->dev, "v4l ctrl handler error: %d\n",
 			ctrl_hdlr->error);
+		v4l2_ctrl_handler_free(ctrl_hdlr);
 		return ctrl_hdlr->error;
 	}
 
-- 
2.25.1


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

end of thread, other threads:[~2023-03-26  9:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-24 17:24 [PATCH] media: hi846: Fix memleak in hi846_init_controls() Wei Chen
2023-03-26  8:50 ` Martin Kepplinger
2023-03-26  9:11   ` Wei Chen

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®