media: i2c: camera cert-c and coverity fixes

Cert-C fixes in camera ar1335, imx219 and imx477 driver.

Cert-C
CID:566165
CID:566166
CID:566168
CID:566169
CID:566170
CID:566171
CID:683423
CID:566021

Coverity
CID:10179834

Bug 3959323

Change-Id: Id68deab8051206b6eae3da917d83c32365186fc5
Signed-off-by: Ankur Pawar <ankurp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2939548
Reviewed-by: Praveen AC <pac@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Ankur Pawar
2023-07-19 22:03:37 -07:00
committed by mobile promotions
parent 1212fd6023
commit f4b8e44a5e
3 changed files with 61 additions and 10 deletions

View File

@@ -341,9 +341,13 @@ static int cam_g_input_status(struct v4l2_subdev *sd, u32 * status)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct camera_common_data *s_data = to_camera_common_data(&client->dev);
struct cam *priv = (struct cam *)s_data->priv;
struct cam *priv;
struct camera_common_power_rail *pw;
if (!s_data)
return -EINVAL;
priv = (struct cam *)s_data->priv;
if (!priv || !priv->pdata)
return -EINVAL;
@@ -373,12 +377,17 @@ static int cam_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *cfg,
int ret;
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct camera_common_data *s_data = to_camera_common_data(&client->dev);
struct cam *priv = (struct cam *)s_data->priv;
struct cam *priv;
int flag = 0, err = 0, mode = 0, retry = 10;
mode = s_data->mode;
if (!s_data)
return -EINVAL;
priv = (struct cam *)s_data->priv;
if (!priv || !priv->pdata)
return -EINVAL;
switch (format->format.code) {
case MEDIA_BUS_FMT_UYVY8_1X16:
priv->format_fourcc = V4L2_PIX_FMT_UYVY;
@@ -787,7 +796,7 @@ static int mcu_stream_config(struct i2c_client *client, uint32_t format,
int mode, int frate_index)
{
struct camera_common_data *s_data = to_camera_common_data(&client->dev);
struct cam *priv = (struct cam *)s_data->priv;
struct cam *priv;
uint32_t payload_len = 0;
@@ -795,6 +804,10 @@ static int mcu_stream_config(struct i2c_client *client, uint32_t format,
uint8_t retcode = 0, cmd_id = 0;
int loop = 0, ret = 0, err = 0, retry=1000;
if (!s_data)
return -EINVAL;
priv = (struct cam *)s_data->priv;
/* lock semaphore */
mutex_lock(&mcu_i2c_mutex);
@@ -938,7 +951,7 @@ static int mcu_get_ctrl(struct i2c_client *client, uint32_t arg_ctrl_id,
uint8_t * ctrl_type, int32_t * curr_val)
{
struct camera_common_data *s_data = to_camera_common_data(&client->dev);
struct cam *priv = (struct cam *)s_data->priv;
struct cam *priv;
uint32_t payload_len = 0;
uint16_t index = 0xFFFF;
@@ -946,6 +959,10 @@ static int mcu_get_ctrl(struct i2c_client *client, uint32_t arg_ctrl_id,
uint32_t ctrl_id = 0;
if (!s_data)
return -EINVAL;
priv = (struct cam *)s_data->priv;
/* lock semaphore */
mutex_lock(&mcu_i2c_mutex);
@@ -1009,7 +1026,7 @@ static int mcu_set_ctrl(struct i2c_client *client, uint32_t arg_ctrl_id,
uint8_t ctrl_type, int32_t curr_val)
{
struct camera_common_data *s_data = to_camera_common_data(&client->dev);
struct cam *priv = (struct cam *)s_data->priv;
struct cam *priv;
uint32_t payload_len = 0;
uint16_t cmd_status = 0, index = 0xFFFF;
@@ -1017,6 +1034,10 @@ static int mcu_set_ctrl(struct i2c_client *client, uint32_t arg_ctrl_id,
int loop = 0, ret = 0, err = 0;
uint32_t ctrl_id = 0;
if (!s_data)
return -EINVAL;
priv = (struct cam *)s_data->priv;
/* lock semaphore */
mutex_lock(&mcu_i2c_mutex);
@@ -2764,10 +2785,21 @@ static void cam_remove(struct i2c_client *client)
#endif
{
struct camera_common_data *s_data = to_camera_common_data(&client->dev);
struct cam *priv = (struct cam *)s_data->priv;
struct cam *priv;
struct device_node *node = client->dev.of_node;
int loop = 0;
int reset_gpio = 0, pwdn_gpio = 0;
if (!s_data) {
dev_err(&client->dev, "camera common data is NULL\n");
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
return -EINVAL;
#else
return;
#endif
}
priv = (struct cam *)s_data->priv;
/* Release the Gpios */
reset_gpio = of_get_named_gpio(node, "reset-gpios", 0);
if (reset_gpio < 0) {

View File

@@ -257,10 +257,9 @@ static int imx219_set_exposure(struct tegracam_device *tc_dev, s64 val)
if (mode->signal_properties.pixel_clock.val == 0 ||
mode->control_properties.exposure_factor == 0 ||
mode->image_properties.line_length)
mode->image_properties.line_length == 0)
return -EINVAL;
fine_integ_time_factor = priv->fine_integ_time *
mode->control_properties.exposure_factor /
mode->signal_properties.pixel_clock.val;
@@ -762,7 +761,17 @@ static int imx219_remove(struct i2c_client *client)
#endif
{
struct camera_common_data *s_data = to_camera_common_data(&client->dev);
struct imx219 *priv = (struct imx219 *)s_data->priv;
struct imx219 *priv;
if (!s_data) {
dev_err(&client->dev, "camera common data is NULL\n");
#if KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE
return -EINVAL;
#else
return;
#endif
}
priv = (struct imx219 *)s_data->priv;
tegracam_v4l2subdev_unregister(priv->tc_dev);
tegracam_device_unregister(priv->tc_dev);

View File

@@ -787,7 +787,17 @@ static int imx477_remove(struct i2c_client *client)
#endif
{
struct camera_common_data *s_data = to_camera_common_data(&client->dev);
struct imx477 *priv = (struct imx477 *)s_data->priv;
struct imx477 *priv;
if (!s_data) {
dev_err(&client->dev, "camera common data is NULL\n");
#if KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE
return -EINVAL;
#else
return;
#endif
}
priv = (struct imx477 *)s_data->priv;
tegracam_v4l2subdev_unregister(priv->tc_dev);
tegracam_device_unregister(priv->tc_dev);