[COMMON] media: smfc: fix resource leak in exynos_smfc_release()
authorCho KyongHo <pullip.cho@samsung.com>
Sat, 19 Sep 2015 11:14:35 +0000 (20:14 +0900)
committerSeungchul Kim <sc377.kim@samsung.com>
Mon, 28 May 2018 05:31:16 +0000 (14:31 +0900)
SMFC driver overrides V4L2 control handlers when a new context is
created but it forgot to release the overridden handlers when the
context is released.

Change-Id: Id241dd029618d3eca7c37da28f8075e5e6a49360
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
drivers/media/platform/exynos/smfc/smfc-v4l2-ioctls.c
drivers/media/platform/exynos/smfc/smfc.c

index bfb09046045def683a2ffcbf2ff33cab1004762f..75112e5825a2ea2b8f7c75847d312d0138584700 100644 (file)
@@ -383,6 +383,8 @@ int smfc_init_controls(struct smfc_dev *smfc,
 
        return 0;
 err:
+       v4l2_ctrl_handler_free(hdlr);
+
        dev_err(smfc->dev, "Failed to install %s control (%d)\n",
                msg, hdlr->error);
        return hdlr->error;
index da27b340b6935759a9ad97845d61bba26cd79601..5da080119b12ee7e5354a3ac99d87de329a411fc 100644 (file)
@@ -444,11 +444,12 @@ static int exynos_smfc_open(struct file *filp)
 
        return 0;
 err_clk:
-       v4l2_fh_del(&ctx->fh);
-       v4l2_fh_exit(&ctx->fh);
        v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
-err_control:
 err_m2m_ctx_init:
+       v4l2_ctrl_handler_free(&ctx->v4l2_ctrlhdlr);
+err_control:
+       v4l2_fh_del(&ctx->fh);
+       v4l2_fh_exit(&ctx->fh);
        kfree(ctx);
        return ret;
 }
@@ -457,8 +458,10 @@ static int exynos_smfc_release(struct file *filp)
 {
        struct smfc_ctx *ctx = v4l2_fh_to_smfc_ctx(filp->private_data);
 
-       v4l2_fh_del(&ctx->fh);
        v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
+       v4l2_ctrl_handler_free(&ctx->v4l2_ctrlhdlr);
+       v4l2_fh_del(&ctx->fh);
+       v4l2_fh_exit(&ctx->fh);
 
        if (!IS_ERR(ctx->smfc->clk_gate)) {
                clk_unprepare(ctx->smfc->clk_gate);