]> git.baikalelectronics.ru Git - kernel.git/commitdiff
media: amphion: free ctrl handler if error is set and return error
authorMing Qian <ming.qian@nxp.com>
Fri, 22 Apr 2022 01:36:21 +0000 (03:36 +0200)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Fri, 13 May 2022 09:02:19 +0000 (11:02 +0200)
The typical behavior is to add all controls, then at the end check if
hdl->error was set, and if so, v4l2_ctrl_handler_free is called and
the error is returned.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/platform/amphion/vdec.c
drivers/media/platform/amphion/venc.c

index 414e5215d8d27a8743721b9fec45e464af527b69..3c02aa2a54aa6c3502465ad7ad71976f0a936ecb 100644 (file)
@@ -162,6 +162,12 @@ static int vdec_ctrl_init(struct vpu_inst *inst)
        if (ctrl)
                ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
 
+       if (inst->ctrl_handler.error) {
+               ret = inst->ctrl_handler.error;
+               v4l2_ctrl_handler_free(&inst->ctrl_handler);
+               return ret;
+       }
+
        ret = v4l2_ctrl_handler_setup(&inst->ctrl_handler);
        if (ret) {
                dev_err(inst->dev, "[%d] setup ctrls fail, ret = %d\n", inst->id, ret);
index 06c873fd0031340403e37f6f4095e369e981d7c4..ba9f49cca155217f8324929385ebf160e8b1ff70 100644 (file)
@@ -682,6 +682,12 @@ static int venc_ctrl_init(struct vpu_inst *inst)
                               ~(1 << V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME),
                               V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME);
 
+       if (inst->ctrl_handler.error) {
+               ret = inst->ctrl_handler.error;
+               v4l2_ctrl_handler_free(&inst->ctrl_handler);
+               return ret;
+       }
+
        ret = v4l2_ctrl_handler_setup(&inst->ctrl_handler);
        if (ret) {
                dev_err(inst->dev, "[%d] setup ctrls fail, ret = %d\n", inst->id, ret);