media: i2c: Fix camera driver Coverity defects

Fix the below Coverity defects for IMX390 and
AR0234 sensor driver

Memory corruptions
CID: 10171410

Unchecked return value
CID: 10171825

Bug 3952896

Change-Id: Iff8a557ea3240a7aafd3e8e66fd6716dd28ac201
Signed-off-by: Ankur Pawar <ankurp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2888806
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Ankur Pawar
2023-04-16 11:44:32 +00:00
committed by mobile promotions
parent f9a0264f89
commit 3be100e555
2 changed files with 12 additions and 4 deletions

View File

@@ -640,6 +640,10 @@ static int ar0234_fill_eeprom(struct tegracam_device *tc_dev,
switch (ctrl->id) {
case TEGRA_CAMERA_CID_STEREO_EEPROM:
if (AR0234_EEPROM_SIZE >
sizeof(struct LiEeprom_Content_Struct))
return -EINVAL;
tmp = kmalloc(sizeof(struct LiEeprom_Content_Struct),
GFP_KERNEL);
if (tmp == NULL)
@@ -649,8 +653,7 @@ static int ar0234_fill_eeprom(struct tegracam_device *tc_dev,
sizeof(struct NvCamSyncSensorCalibData));
memset(ctrl->p_new.p, 0,
sizeof(struct NvCamSyncSensorCalibData));
memcpy(tmp, priv->eeprom_buf,
sizeof(struct LiEeprom_Content_Struct));
memcpy(tmp, priv->eeprom_buf, AR0234_EEPROM_SIZE);
if (priv->sync_sensor_index == 1)
priv->EepromCalib.cam_intr = tmp->left_cam_intr;

View File

@@ -716,8 +716,13 @@ static int imx390_board_setup(struct imx390 *priv)
}
for (i = 0; i < priv->g_ctx.num_streams; i++) {
of_property_read_string_index(gmsl, "streams", i,
&str_value1[i]);
err = of_property_read_string_index(gmsl, "streams", i,
&str_value1[i]);
if (err < 0) {
dev_err(dev, "Failed to get streams index\n");
goto error;
}
if (!str_value1[i]) {
dev_err(dev, "invalid stream info\n");
err = -EINVAL;