]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: dc: fix Coverity issues
authorDeepak Nibade <dnibade@nvidia.com>
Sun, 8 Dec 2013 09:39:18 +0000 (15:09 +0530)
committerJon Mayo <jmayo@nvidia.com>
Fri, 13 Dec 2013 18:57:33 +0000 (10:57 -0800)
- fix dereference before NULL check
Coverity id : 24636
- fix unchecked return value
Coverity id : 25027
Coverity id : 25028
Coverity id : 25243
Coverity id : 25244

Bug 1416640

Change-Id: If9e7ff59267cfc39d10f99061162176b4c49a34c
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/339693
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: Sumit Singh <sumsingh@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Jon Mayo <jmayo@nvidia.com>
drivers/video/tegra/dc/dsi.c
drivers/video/tegra/dc/dsi_debug.c
drivers/video/tegra/dc/edid.c

index 0a1e6d8e93efc32f3a29120a6ffe0f266cb53998..21b3cffa2131639958a74c0956967d0e94e1fc27 100644 (file)
@@ -3027,16 +3027,22 @@ int tegra_dsi_start_host_cmd_v_blank_video(struct tegra_dc_dsi_data *dsi,
                if (err < 0) {
                        dev_err(&dc->ndev->dev,
                                "dsi: not able to set to hs mode\n");
-                       return err;
+                       goto fail;
                }
                tegra_dsi_start_dc_stream(dc, dsi);
                tegra_dsi_wait_frame_end(dc, dsi, 2);
-               tegra_dsi_set_to_lp_mode(dc, dsi, DSI_LP_OP_WRITE);
+               err = tegra_dsi_set_to_lp_mode(dc, dsi, DSI_LP_OP_WRITE);
+               if (err < 0) {
+                       dev_err(&dc->ndev->dev,
+                               "dsi: not able to set to lp mode\n");
+                       goto fail;
+               }
        }
+ fail:
        tegra_dc_dsi_release_host(dc);
        tegra_dc_io_end(dc);
 
-       return 0;
+       return err;
 }
 EXPORT_SYMBOL(tegra_dsi_start_host_cmd_v_blank_video);
 
index 89908734b317e238b725c2e7d757208633f703ac..4751dec7af7d7587985402da163234bfd5b50e41 100644 (file)
@@ -242,9 +242,10 @@ static ssize_t read_panel_set(struct file *file, const char  *buf,
        struct tegra_dc_dsi_data *dsi = s->private;
        struct tegra_dc *dc = dsi->dc;
 
-       sscanf(buf, "%x %x", &max_ret_payload_size, &panel_reg_addr);
-               dev_info(&dc->ndev->dev, "max ret payload size:0x%x\npanel reg addr:0x%x\n",
-                               max_ret_payload_size, panel_reg_addr);
+       if (sscanf(buf, "%x %x", &max_ret_payload_size, &panel_reg_addr) != 2)
+               return -EINVAL;
+       dev_info(&dc->ndev->dev, "max ret payload size:0x%x\npanel reg addr:0x%x\n",
+                       max_ret_payload_size, panel_reg_addr);
 
                return count;
 }
@@ -332,7 +333,9 @@ static ssize_t host_cmd_v_blank_dcs_get_cmd(struct file *file,
                return count;
        }
 
-       sscanf(buf, "%x %x %x", &data_id, &command_value, &command_value1);
+       if (sscanf(buf, "%x %x %x", &data_id, &command_value, &command_value1)
+                       != 3)
+               return -EINVAL;
        dev_info(&dc->ndev->dev, "data id taken :0x%x\n", data_id);
        dev_info(&dc->ndev->dev, "command value taken :0x%x\n", command_value);
        dev_info(&dc->ndev->dev, "second command value taken :0x%x\n",
@@ -403,8 +406,9 @@ static ssize_t write_data_get_cmd(struct file *file,
        struct tegra_dc_dsi_data *dsi = s->private;
        struct tegra_dc *dc = dsi->dc;
 
-       sscanf(buf, "%x %x %x", &data_id,
-                                       &command_value, &command_value1);
+       if (sscanf(buf, "%x %x %x", &data_id,
+                               &command_value, &command_value1) != 3)
+               return -EINVAL;
        dev_info(&dc->ndev->dev, "data_id taken :0x%x\n", data_id);
        dev_info(&dc->ndev->dev, "command value taken :0x%x\n", command_value);
        dev_info(&dc->ndev->dev, "second command value taken :0x%x\n",
index 1a9b76476864e18c5338316b297fb0e5fd203828..b7ab9a75b5f8895219ab4d014b955f5024551c14 100644 (file)
@@ -208,11 +208,16 @@ int tegra_edid_parse_ext_block(const u8 *raw, int idx,
        int i;
        bool basic_audio = false;
 
+       if (!edid) {
+               pr_err("%s: invalid argument\n", __func__);
+               return -EINVAL;
+       }
+
        edid->support_audio = 0;
        ptr = &raw[0];
 
        /* If CEA 861 block get info for eld struct */
-       if (edid && ptr) {
+       if (ptr) {
                if (*ptr <= 3)
                        edid->eld.eld_ver = 0x02;
                edid->eld.cea_edid_ver = ptr[1];