Skip to content

Commit bd5811e

Browse files
ZhangShuronggregkh
authored andcommitted
media: ov2659: Fix memory leaks in ov2659_probe()
commit 76142b1 upstream. ov2659_probe() doesn't properly free control handler resources in failure paths, causing memory leaks. Add v4l2_ctrl_handler_free() to prevent these memory leaks and reorder the ctrl_handler assignment for better code flow. Fixes: c4c0283 ("[media] media: i2c: add support for omnivision's ov2659 sensor") Cc: stable@vger.kernel.org Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3681d9a commit bd5811e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/media/i2c/ov2659.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1469,14 +1469,15 @@ static int ov2659_probe(struct i2c_client *client)
14691469
V4L2_CID_TEST_PATTERN,
14701470
ARRAY_SIZE(ov2659_test_pattern_menu) - 1,
14711471
0, 0, ov2659_test_pattern_menu);
1472-
ov2659->sd.ctrl_handler = &ov2659->ctrls;
14731472

14741473
if (ov2659->ctrls.error) {
14751474
dev_err(&client->dev, "%s: control initialization error %d\n",
14761475
__func__, ov2659->ctrls.error);
1476+
v4l2_ctrl_handler_free(&ov2659->ctrls);
14771477
return ov2659->ctrls.error;
14781478
}
14791479

1480+
ov2659->sd.ctrl_handler = &ov2659->ctrls;
14801481
sd = &ov2659->sd;
14811482
client->flags |= I2C_CLIENT_SCCB;
14821483

0 commit comments

Comments
 (0)