video: tegra: host: fix Coverity issues
Deepak Nibade [Tue, 3 Dec 2013 12:26:18 +0000 (17:26 +0530)]
- fix unchecked return value from sscanf
Coverity id : 25029
- fix explicit NULL dereference of pdata
Coverity id : 25086

Bug 1416640

Change-Id: I56749f9e15d70b9bffaa85435a6d39a301413cab
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/337790
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>

drivers/video/tegra/host/isp/isp.c
drivers/video/tegra/host/vic03/vic03.c

index 59d83a9..d2d3487 100644 (file)
@@ -81,7 +81,8 @@ static int isp_probe(struct platform_device *dev)
                if (match)
                        pdata = (struct nvhost_device_data *)match->data;
 #ifdef TEGRA_12X_OR_HIGHER_CONFIG
-               sscanf(dev->name, "isp.%1d", &dev_id);
+               if (sscanf(dev->name, "isp.%1d", &dev_id) != 1)
+                       return -EINVAL;
                if (dev_id == T12_ISPB_DEV_ID)
                        pdata = &t124_ispb_info;
 #endif
index 299b65e..0d12b54 100644 (file)
@@ -612,6 +612,11 @@ static int vic03_probe(struct platform_device *dev)
        } else
                pdata = (struct nvhost_device_data *)dev->dev.platform_data;
 
+       if (!pdata) {
+               dev_err(&dev->dev, "no platform data\n");
+               return -ENODATA;
+       }
+
        nvhost_dbg_fn("dev:%p pdata:%p", dev, pdata);
 
        pdata->pdev = dev;