Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

media: i2c: imx214: Rearrange control initialization

Smatch is confused by the control initialization logic. It assumes that
there can be a case where imx214->link_freq can be NULL and ctrls_init
returns 0.

Re-arrange the function to make smatch happy.

This patch fixes this smatch error:
drivers/media/i2c/imx214.c:1109 imx214_ctrls_init() error: we previously assumed 'imx214->link_freq' could be null (see line 1017)

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>

authored by

Ricardo Ribalda and committed by
Hans Verkuil
15ac3d54 e687f5ca

+6 -9
+6 -9
drivers/media/i2c/imx214.c
··· 1014 1014 V4L2_CID_LINK_FREQ, 1015 1015 imx214->bus_cfg.nr_of_link_frequencies - 1, 1016 1016 0, imx214->bus_cfg.link_frequencies); 1017 - if (imx214->link_freq) 1018 - imx214->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; 1019 1017 1020 1018 /* 1021 1019 * WARNING! ··· 1036 1038 imx214->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &imx214_ctrl_ops, 1037 1039 V4L2_CID_HBLANK, hblank, hblank, 1038 1040 1, hblank); 1039 - if (imx214->hblank) 1040 - imx214->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; 1041 - 1042 1041 exposure_max = mode->vts_def - IMX214_EXPOSURE_OFFSET; 1043 1042 exposure_def = min(exposure_max, IMX214_EXPOSURE_DEFAULT); 1044 1043 imx214->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &imx214_ctrl_ops, ··· 1055 1060 1056 1061 imx214->hflip = v4l2_ctrl_new_std(ctrl_hdlr, &imx214_ctrl_ops, 1057 1062 V4L2_CID_HFLIP, 0, 1, 1, 0); 1058 - if (imx214->hflip) 1059 - imx214->hflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT; 1060 1063 1061 1064 imx214->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &imx214_ctrl_ops, 1062 1065 V4L2_CID_VFLIP, 0, 1, 1, 0); 1063 - if (imx214->vflip) 1064 - imx214->vflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT; 1065 1066 1066 1067 v4l2_ctrl_cluster(2, &imx214->hflip); 1067 1068 ··· 1096 1105 dev_err(imx214->dev, "failed to add controls: %d\n", ret); 1097 1106 return ret; 1098 1107 } 1108 + 1109 + /* Now that the controls have been properly created, set their flags. */ 1110 + imx214->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; 1111 + imx214->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; 1112 + imx214->hflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT; 1113 + imx214->vflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT; 1099 1114 1100 1115 ret = imx214_pll_update(imx214); 1101 1116 if (ret < 0) {