Browse Source

drm/msm: fix potential NULL pointer dereference

The dereference to 'pdata' should be moved below the NULL test.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Wei Yongjun 11 years ago
parent
commit
aea6a64c38
1 changed files with 2 additions and 1 deletions
  1. 2 1
      drivers/gpu/drm/msm/msm_gpu.c

+ 2 - 1
drivers/gpu/drm/msm/msm_gpu.c

@@ -29,13 +29,14 @@
 static void bs_init(struct msm_gpu *gpu, struct platform_device *pdev)
 static void bs_init(struct msm_gpu *gpu, struct platform_device *pdev)
 {
 {
 	struct drm_device *dev = gpu->dev;
 	struct drm_device *dev = gpu->dev;
-	struct kgsl_device_platform_data *pdata = pdev->dev.platform_data;
+	struct kgsl_device_platform_data *pdata;
 
 
 	if (!pdev) {
 	if (!pdev) {
 		dev_err(dev->dev, "could not find dtv pdata\n");
 		dev_err(dev->dev, "could not find dtv pdata\n");
 		return;
 		return;
 	}
 	}
 
 
+	pdata = pdev->dev.platform_data;
 	if (pdata->bus_scale_table) {
 	if (pdata->bus_scale_table) {
 		gpu->bsc = msm_bus_scale_register_client(pdata->bus_scale_table);
 		gpu->bsc = msm_bus_scale_register_client(pdata->bus_scale_table);
 		DBG("bus scale client: %08x", gpu->bsc);
 		DBG("bus scale client: %08x", gpu->bsc);