Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: rj54n1cb0c: Fix memleak in rj54n1_probe()

rj54n1_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: f187352dcd45 ("media: i2c: Copy rj54n1cb0c soc_camera sensor driver")
Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>

authored by

Zhang Shurong and committed by
Hans Verkuil
fda55673 1eb1d48c

+6 -3
+6 -3
drivers/media/i2c/rj54n1cb0c.c
··· 1329 1329 V4L2_CID_GAIN, 0, 127, 1, 66); 1330 1330 v4l2_ctrl_new_std(&rj54n1->hdl, &rj54n1_ctrl_ops, 1331 1331 V4L2_CID_AUTO_WHITE_BALANCE, 0, 1, 1, 1); 1332 - rj54n1->subdev.ctrl_handler = &rj54n1->hdl; 1333 - if (rj54n1->hdl.error) 1334 - return rj54n1->hdl.error; 1335 1332 1333 + if (rj54n1->hdl.error) { 1334 + ret = rj54n1->hdl.error; 1335 + goto err_free_ctrl; 1336 + } 1337 + 1338 + rj54n1->subdev.ctrl_handler = &rj54n1->hdl; 1336 1339 rj54n1->clk_div = clk_div; 1337 1340 rj54n1->rect.left = RJ54N1_COLUMN_SKIP; 1338 1341 rj54n1->rect.top = RJ54N1_ROW_SKIP;