OSDN Git Service

msm: camera: Fixing NULL dereference in sensor code
authorSamyukta Mogily <smogily@codeaurora.org>
Thu, 4 May 2017 09:36:04 +0000 (15:06 +0530)
committerSamyukta Mogily <smogily@codeaurora.org>
Fri, 5 May 2017 06:07:25 +0000 (11:37 +0530)
Fixing issues where we are referring to a null pointer.

Change-Id: I6ae18f61a9dc65fbec5650baf9b1d1fb7ad59262
Signed-off-by: Samyukta Mogily <smogily@codeaurora.org>
drivers/media/platform/msm/camera_v2/sensor/eeprom/msm_eeprom.c
drivers/media/platform/msm/camera_v2/sensor/msm_sensor_driver.c

index e60947e..31d2fdc 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -1269,6 +1269,11 @@ static int msm_eeprom_spi_remove(struct spi_device *sdev)
                return 0;
        }
 
+       if (!e_ctrl->eboard_info) {
+               pr_err("%s: board info is NULL\n", __func__);
+               return 0;
+       }
+
        msm_camera_i2c_dev_put_clk_info(
                &e_ctrl->i2c_client.spi_client->spi_master->dev,
                &e_ctrl->eboard_info->power_info.clk_info,
@@ -1788,6 +1793,11 @@ static int msm_eeprom_platform_remove(struct platform_device *pdev)
                return 0;
        }
 
+       if (!e_ctrl->eboard_info) {
+               pr_err("%s: board info is NULL\n", __func__);
+               return 0;
+       }
+
        msm_camera_put_clk_info(e_ctrl->pdev,
                &e_ctrl->eboard_info->power_info.clk_info,
                &e_ctrl->eboard_info->power_info.clk_ptr,
index 1dd2b0d..31b9524 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -1341,18 +1341,20 @@ static int32_t msm_sensor_driver_i2c_probe(struct i2c_client *client,
        if (s_ctrl->sensor_i2c_client != NULL) {
                s_ctrl->sensor_i2c_client->client = client;
                s_ctrl->sensordata->power_info.dev = &client->dev;
+
+               /* Get clocks information */
+               rc = msm_camera_i2c_dev_get_clk_info(
+                       &s_ctrl->sensor_i2c_client->client->dev,
+                       &s_ctrl->sensordata->power_info.clk_info,
+                       &s_ctrl->sensordata->power_info.clk_ptr,
+                       &s_ctrl->sensordata->power_info.clk_info_size);
+               if (rc < 0) {
+                       pr_err("failed: msm_camera_i2c_dev_get_clk_info rc %d",
+                               rc);
+                       goto FREE_S_CTRL;
+               }
+               return rc;
        }
-       /* Get clocks information */
-       rc = msm_camera_i2c_dev_get_clk_info(
-               &s_ctrl->sensor_i2c_client->client->dev,
-               &s_ctrl->sensordata->power_info.clk_info,
-               &s_ctrl->sensordata->power_info.clk_ptr,
-               &s_ctrl->sensordata->power_info.clk_info_size);
-       if (rc < 0) {
-               pr_err("failed: msm_camera_i2c_dev_get_clk_info rc %d", rc);
-               goto FREE_S_CTRL;
-       }
-       return rc;
 FREE_S_CTRL:
        kfree(s_ctrl);
        return rc;