Check that no error happened during adding controls to the driver's
control handler. Print an error message and bail out if there was one.

Signed-off-by: Sakari Ailus <sakari.ai...@linux.intel.com>
---
 drivers/media/i2c/ov7740.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/media/i2c/ov7740.c b/drivers/media/i2c/ov7740.c
index cbfa5a3327f6..0c15b67f3c34 100644
--- a/drivers/media/i2c/ov7740.c
+++ b/drivers/media/i2c/ov7740.c
@@ -1000,6 +1000,13 @@ static int ov7740_init_controls(struct ov7740 *ov7740)
                                        V4L2_EXPOSURE_MANUAL, 0,
                                        V4L2_EXPOSURE_AUTO);
 
+       if (ctrl_hdlr->error) {
+               ret = ctrl_hdlr->error;
+               dev_err(&client->dev, "controls initialisation failed (%d)\n",
+                       ret);
+               goto error;
+       }
+
        v4l2_ctrl_auto_cluster(3, &ov7740->auto_wb, 0, false);
        v4l2_ctrl_auto_cluster(2, &ov7740->auto_gain, 0, true);
        v4l2_ctrl_auto_cluster(2, &ov7740->auto_exposure,
-- 
2.11.0

Reply via email to