[PATCH] media: exynos4-is: Free the control handler if fimc_ctrls_create() fails

Wentao Liang vulab at iscas.ac.cn
Tue Nov 3 01:46:12 PST 2026


v4l2_ctrl_handler_init() allocates the handler's bucket array, and each
subsequent v4l2_ctrl_new_std() call allocates a control.  When one of
those calls fails it only records the error in handler->error.
fimc_ctrls_create() returns that error with ctrls->ready left false, so
neither caller calls fimc_ctrls_delete(), and that function would not
free the handler in that state anyway.  The bucket array and the
controls created so far are leaked.

Free the handler before returning the error.

Fixes: 9448ab7dec30 ("[media] s5p-fimc: Add color effect control")
Cc: stable at vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab at iscas.ac.cn>
---
 drivers/media/platform/samsung/exynos4-is/fimc-core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/samsung/exynos4-is/fimc-core.c b/drivers/media/platform/samsung/exynos4-is/fimc-core.c
index b36812ad25c0..8e6dd602aa79 100644
--- a/drivers/media/platform/samsung/exynos4-is/fimc-core.c
+++ b/drivers/media/platform/samsung/exynos4-is/fimc-core.c
@@ -606,6 +606,8 @@ int fimc_ctrls_create(struct fimc_ctx *ctx)
 	if (!handler->error) {
 		v4l2_ctrl_cluster(2, &ctrls->colorfx);
 		ctrls->ready = true;
+	} else {
+		v4l2_ctrl_handler_free(handler);
 	}
 
 	return handler->error;
-- 
2.34.1




More information about the linux-arm-kernel mailing list