@@ -1743,7 +1743,7 @@ struct msm_gpu *a5xx_gpu_init(struct drm_device *dev)
{
struct msm_drm_private *priv = dev->dev_private;
struct platform_device *pdev = priv->gpu_pdev;
- struct adreno_platform_config *config = pdev->dev.platform_data;
+ struct adreno_platform_config *config;
struct a5xx_gpu *a5xx_gpu = NULL;
struct adreno_gpu *adreno_gpu;
struct msm_gpu *gpu;
@@ -1755,6 +1755,8 @@ struct msm_gpu *a5xx_gpu_init(struct drm_device *dev)
return ERR_PTR(-ENXIO);
}
+ config = pdev->dev.platform_data;
+
a5xx_gpu = kzalloc(sizeof(*a5xx_gpu), GFP_KERNEL);
if (!a5xx_gpu)
return ERR_PTR(-ENOMEM);
Smatch complains: drivers/gpu/drm/msm/adreno/a5xx_gpu.c:1753 a5xx_gpu_init() warn: variable dereferenced before check 'pdev' (see line 1746) When no device is defined, dereferencing pdev is a NULL dereference. Fix this by dereferencing pdev to get the config post the NULL check. Fixes: 736a93273656 ("drm/msm/a5xx: really check for A510 in a5xx_gpu_init") Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com> --- This is based on static analysis, only compile tested. --- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)