[PATCH] media: i2c: ov6211: Release controls after control creation failure
From: Wentao Liang
Date: Tue Nov 03 2026 - 03:51:12 EST
ov6211_init_controls() returns the handler error directly when a control
cannot be created. Controls that were successfully created earlier and
the handler's allocation are left behind. The probe caller powers the
sensor off on this error and does not free the handler.
Use the existing error_free_hdlr path for this failure, just as for the
subsequent firmware-property parsing and control initialization errors.
Save and return the original control error.
Fixes: fd7cb868e309 ("media: i2c: Add OmniVision OV6211 image sensor driver")
Cc: stable@xxxxxxxxxxxxxxx
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/media/i2c/ov6211.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/ov6211.c b/drivers/media/i2c/ov6211.c
index 2ad31b2c5249..d82aacc7dcfb 100644
--- a/drivers/media/i2c/ov6211.c
+++ b/drivers/media/i2c/ov6211.c
@@ -360,8 +360,10 @@ static int ov6211_init_controls(struct ov6211 *ov6211)
ARRAY_SIZE(ov6211_test_pattern_menu) - 1,
0, 0, ov6211_test_pattern_menu);
- if (ctrl_hdlr->error)
- return ctrl_hdlr->error;
+ if (ctrl_hdlr->error) {
+ ret = ctrl_hdlr->error;
+ goto error_free_hdlr;
+ }
ret = v4l2_fwnode_device_parse(ov6211->dev, &props);
if (ret)
--
2.34.1