mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: exynos4-is: Free the control handler if fimc_ctrls_create() fails
@ 2026-11-03  9:46 Wentao Liang
  2026-11-03 10:27 ` Krzysztof Kozlowski
  2026-11-04  7:21 ` Krzysztof Kozlowski
  0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2026-11-03  9:46 UTC (permalink / raw)
  To: Sylwester Nawrocki, Mauro Carvalho Chehab, Krzysztof Kozlowski,
	Peter Griffin, Alim Akhtar
  Cc: linux-media, linux-arm-kernel, linux-samsung-soc, linux-kernel,
	Wentao Liang, stable

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@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-04  7:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03  9:46 [PATCH] media: exynos4-is: Free the control handler if fimc_ctrls_create() fails Wentao Liang
2026-11-03 10:27 ` Krzysztof Kozlowski
2026-11-04  7:21 ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®