The control handler must be freed in the probe error path and in the
remove handler.

Signed-off-by: Laurent Pinchart <laurent.pinch...@ideasonboard.com>
---
 drivers/media/i2c/mt9v032.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 3f356cb..24ea6fd 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -830,8 +830,11 @@ static int mt9v032_probe(struct i2c_client *client,
 
        mt9v032->pad.flags = MEDIA_PAD_FL_SOURCE;
        ret = media_entity_init(&mt9v032->subdev.entity, 1, &mt9v032->pad, 0);
-       if (ret < 0)
+
+       if (ret < 0) {
+               v4l2_ctrl_handler_free(&mt9v032->ctrls);
                kfree(mt9v032);
+       }
 
        return ret;
 }
@@ -841,9 +844,11 @@ static int mt9v032_remove(struct i2c_client *client)
        struct v4l2_subdev *subdev = i2c_get_clientdata(client);
        struct mt9v032 *mt9v032 = to_mt9v032(subdev);
 
+       v4l2_ctrl_handler_free(&mt9v032->ctrls);
        v4l2_device_unregister_subdev(subdev);
        media_entity_cleanup(&subdev->entity);
        kfree(mt9v032);
+
        return 0;
 }
 
-- 
1.8.1.5

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to