summaryrefslogtreecommitdiffstats
path: root/drivers/media/platform
diff options
context:
space:
mode:
authorMing Qian <ming.qian@nxp.com>2022-04-22 03:36:21 +0200
committerMauro Carvalho Chehab <mchehab@kernel.org>2022-05-13 11:02:19 +0200
commit37ed01d5f27fe67e0a86b0fe8a053f054a7f3948 (patch)
treeffc518808297a2b237196a7f8c362b8b9fc0c398 /drivers/media/platform
parentmedia: amphion: handle picture skipped event (diff)
downloadlinux-37ed01d5f27fe67e0a86b0fe8a053f054a7f3948.tar.xz
linux-37ed01d5f27fe67e0a86b0fe8a053f054a7f3948.zip
media: amphion: free ctrl handler if error is set and return error
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>
Diffstat (limited to 'drivers/media/platform')
-rw-r--r--drivers/media/platform/amphion/vdec.c6
-rw-r--r--drivers/media/platform/amphion/venc.c6
2 files changed, 12 insertions, 0 deletions
diff --git a/drivers/media/platform/amphion/vdec.c b/drivers/media/platform/amphion/vdec.c
index 414e5215d8d2..3c02aa2a54aa 100644
--- a/drivers/media/platform/amphion/vdec.c
+++ b/drivers/media/platform/amphion/vdec.c
@@ -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);
diff --git a/drivers/media/platform/amphion/venc.c b/drivers/media/platform/amphion/venc.c
index 06c873fd0031..ba9f49cca155 100644
--- a/drivers/media/platform/amphion/venc.c
+++ b/drivers/media/platform/amphion/venc.c
@@ -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);