From: Cho KyongHo Date: Sat, 19 Sep 2015 11:14:35 +0000 (+0900) Subject: [COMMON] media: smfc: fix resource leak in exynos_smfc_release() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1d717de343c6878ef4d7ce537bca2f9e5d74aa86;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [COMMON] media: smfc: fix resource leak in exynos_smfc_release() 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 --- diff --git a/drivers/media/platform/exynos/smfc/smfc-v4l2-ioctls.c b/drivers/media/platform/exynos/smfc/smfc-v4l2-ioctls.c index bfb09046045d..75112e5825a2 100644 --- a/drivers/media/platform/exynos/smfc/smfc-v4l2-ioctls.c +++ b/drivers/media/platform/exynos/smfc/smfc-v4l2-ioctls.c @@ -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; diff --git a/drivers/media/platform/exynos/smfc/smfc.c b/drivers/media/platform/exynos/smfc/smfc.c index da27b340b693..5da080119b12 100644 --- a/drivers/media/platform/exynos/smfc/smfc.c +++ b/drivers/media/platform/exynos/smfc/smfc.c @@ -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);