[PATCH] staging: sunxi: cedrus: centralize cedrus_open exit

Ian Cowan ian at linux.cowan.aero
Sat Apr 23 11:01:11 PDT 2022


Refactor the cedrus_open() function so that there is only one exit to
the function instead of 2. This prevents a future change from preventing
the mutex from being unlocked after a successful exit.

Signed-off-by: Ian Cowan <ian at linux.cowan.aero>
---
 drivers/staging/media/sunxi/cedrus/cedrus.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c
index 68b3dcdb5df3..5236d9e4f4e8 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus.c
@@ -348,14 +348,14 @@ static int cedrus_open(struct file *file)
 
 	v4l2_fh_add(&ctx->fh);
 
-	mutex_unlock(&dev->dev_mutex);
-
-	return 0;
+	ret = 0;
+	goto succ_unlock;
 
 err_ctrls:
 	v4l2_ctrl_handler_free(&ctx->hdl);
 err_free:
 	kfree(ctx);
+succ_unlock:
 	mutex_unlock(&dev->dev_mutex);
 
 	return ret;
-- 
2.35.1




More information about the linux-arm-kernel mailing list