diff mbox series

[12/25] media: rcar_fdp1: simplify error check logic at fdp_open()

Message ID c9e7c9b02841c149b0127a7658d2a3e2828cfb90.1620207353.git.mchehab+huawei@kernel.org
State Accepted
Commit fa9f443f7c962d072d150472e2bb77de39817a9a
Headers show
Series [01/25] staging: media: rkvdec: fix pm_runtime_get_sync() usage count | expand

Commit Message

Mauro Carvalho Chehab May 5, 2021, 9:42 a.m. UTC
Avoid some code duplication by moving the common error path
logit at fdp_open().

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/platform/rcar_fdp1.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Comments

Sergei Shtylyov May 5, 2021, 9:48 a.m. UTC | #1
Hello!

On 05.05.2021 12:42, Mauro Carvalho Chehab wrote:

> Avoid some code duplication by moving the common error path
> logit at fdp_open().

    Logic?

> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
[...]

MBR, Sergei
diff mbox series

Patch

diff --git a/drivers/media/platform/rcar_fdp1.c b/drivers/media/platform/rcar_fdp1.c
index 01c1fbb97bf6..d26413fa5205 100644
--- a/drivers/media/platform/rcar_fdp1.c
+++ b/drivers/media/platform/rcar_fdp1.c
@@ -2117,9 +2117,7 @@  static int fdp1_open(struct file *file)
 
 	if (ctx->hdl.error) {
 		ret = ctx->hdl.error;
-		v4l2_ctrl_handler_free(&ctx->hdl);
-		kfree(ctx);
-		goto done;
+		goto error_ctx;
 	}
 
 	ctx->fh.ctrl_handler = &ctx->hdl;
@@ -2133,10 +2131,7 @@  static int fdp1_open(struct file *file)
 
 	if (IS_ERR(ctx->fh.m2m_ctx)) {
 		ret = PTR_ERR(ctx->fh.m2m_ctx);
-
-		v4l2_ctrl_handler_free(&ctx->hdl);
-		kfree(ctx);
-		goto done;
+		goto error_ctx;
 	}
 
 	/* Perform any power management required */
@@ -2147,6 +2142,12 @@  static int fdp1_open(struct file *file)
 	dprintk(fdp1, "Created instance: %p, m2m_ctx: %p\n",
 		ctx, ctx->fh.m2m_ctx);
 
+	mutex_unlock(&fdp1->dev_mutex);
+	return 0;
+
+error_ctx:
+	v4l2_ctrl_handler_free(&ctx->hdl);
+	kfree(ctx);
 done:
 	mutex_unlock(&fdp1->dev_mutex);
 	return ret;