media: hi846: Fix memleak in hi846_init_controls()
[ Upstream commit 2649c1a20e8e399ee955d0e22192f9992662c3d2 ]
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.
Fixes: e8c0882685
("media: i2c: add driver for the SK Hynix Hi-846 8M pixel camera")
Signed-off-by: Wei Chen <harperchen1110@gmail.com>
Reviewed-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
893b267ccc
commit
fd22e8c8c3
@ -1472,21 +1472,26 @@ static int hi846_init_controls(struct hi846 *hi846)
|
|||||||
if (ctrl_hdlr->error) {
|
if (ctrl_hdlr->error) {
|
||||||
dev_err(&client->dev, "v4l ctrl handler error: %d\n",
|
dev_err(&client->dev, "v4l ctrl handler error: %d\n",
|
||||||
ctrl_hdlr->error);
|
ctrl_hdlr->error);
|
||||||
return ctrl_hdlr->error;
|
ret = ctrl_hdlr->error;
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = v4l2_fwnode_device_parse(&client->dev, &props);
|
ret = v4l2_fwnode_device_parse(&client->dev, &props);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
goto error;
|
||||||
|
|
||||||
ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &hi846_ctrl_ops,
|
ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &hi846_ctrl_ops,
|
||||||
&props);
|
&props);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
goto error;
|
||||||
|
|
||||||
hi846->sd.ctrl_handler = ctrl_hdlr;
|
hi846->sd.ctrl_handler = ctrl_hdlr;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
error:
|
||||||
|
v4l2_ctrl_handler_free(ctrl_hdlr);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hi846_set_video_mode(struct hi846 *hi846, int fps)
|
static int hi846_set_video_mode(struct hi846 *hi846, int fps)
|
||||||
|
Loading…
Reference in New Issue
Block a user