Skip to content

Commit

Permalink
media: ov6650: Fix control handler not freed on init error
Browse files Browse the repository at this point in the history
BugLink: https://bugs.launchpad.net/bugs/1860490

[ Upstream commit c404af9 ]

Since commit afd9690 ("[media] ov6650: convert to the control
framework"), if an error occurs during initialization of a control
handler, resources possibly allocated to the handler are not freed
before device initialiaton is aborted.  Fix it.

Fixes: afd9690 ("[media] ov6650: convert to the control framework")
Signed-off-by: Janusz Krzysztofik <[email protected]>
Signed-off-by: Sakari Ailus <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Kamal Mostafa <[email protected]>
Signed-off-by: Khalid Elmously <[email protected]>
  • Loading branch information
jkrzyszt authored and kelmously committed Jan 29, 2020
1 parent 0b0b37e commit 0c90382
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions drivers/media/i2c/ov6650.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,8 +993,10 @@ static int ov6650_probe(struct i2c_client *client,
V4L2_CID_GAMMA, 0, 0xff, 1, 0x12);

priv->subdev.ctrl_handler = &priv->hdl;
if (priv->hdl.error)
return priv->hdl.error;
if (priv->hdl.error) {
ret = priv->hdl.error;
goto ectlhdlfree;
}

v4l2_ctrl_auto_cluster(2, &priv->autogain, 0, true);
v4l2_ctrl_auto_cluster(3, &priv->autowb, 0, true);
Expand All @@ -1012,8 +1014,10 @@ static int ov6650_probe(struct i2c_client *client,
priv->subdev.internal_ops = &ov6650_internal_ops;

ret = v4l2_async_register_subdev(&priv->subdev);
if (ret)
v4l2_ctrl_handler_free(&priv->hdl);
if (!ret)
return 0;
ectlhdlfree:
v4l2_ctrl_handler_free(&priv->hdl);

return ret;
}
Expand Down

0 comments on commit 0c90382

Please sign in to comment.