[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250829-imx214-smatch-v1-1-f3d1653b48e4@chromium.org>
Date: Fri, 29 Aug 2025 12:21:00 +0000
From: Ricardo Ribalda <ribalda@...omium.org>
To: Ricardo Ribalda <ribalda@...nel.org>,
Hans Verkuil <hverkuil+cisco@...nel.org>
Cc: linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
Ricardo Ribalda <ribalda@...omium.org>
Subject: [PATCH] media: i2c: imx214: Exit early on control init errors
Now we try to initialize all the controls and at the very end check
ctrl_hdlr->error to check if one of them has failed.
This confuses smatch, who do not know how to track the state of
imx214->link_freq.
drivers/media/i2c/imx214.c:1109 imx214_ctrls_init() error: we previously assumed 'imx214->link_freq' could be null (see line 1017)
Fix this by exiting early on control initi errors.
Signed-off-by: Ricardo Ribalda <ribalda@...omium.org>
---
Right now we are handling this with a quirk in media-ci, if Dan cannot
fix smatch in a kernel cycle we should merge this patch.
---
drivers/media/i2c/imx214.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c
index 94ebe625c9e6ee0fb67fe1d89b48b2f1bf58ffc6..7da9e8fa2b622adba53fa6b544bca9859da23e3e 100644
--- a/drivers/media/i2c/imx214.c
+++ b/drivers/media/i2c/imx214.c
@@ -1014,8 +1014,10 @@ static int imx214_ctrls_init(struct imx214 *imx214)
V4L2_CID_LINK_FREQ,
imx214->bus_cfg.nr_of_link_frequencies - 1,
0, imx214->bus_cfg.link_frequencies);
- if (imx214->link_freq)
- imx214->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
+ if (!imx214->link_freq)
+ goto err_init_ctrl;
+
+ imx214->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
/*
* WARNING!
@@ -1101,6 +1103,7 @@ static int imx214_ctrls_init(struct imx214 *imx214)
ret = ctrl_hdlr->error;
if (ret) {
+err_init_ctrl:
v4l2_ctrl_handler_free(ctrl_hdlr);
dev_err(imx214->dev, "failed to add controls: %d\n", ret);
return ret;
---
base-commit: 16428e2449ab96cce27be6ab17b750b404c76c7c
change-id: 20250829-imx214-smatch-c4d4d47428d5
Best regards,
--
Ricardo Ribalda <ribalda@...omium.org>
Powered by blists - more mailing lists