aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArchit Taneja <architt@codeaurora.org>2017-12-22 05:11:13 -0500
committerRob Clark <robdclark@gmail.com>2018-01-03 09:36:17 -0500
commit9dcfbc182f1aac0aa5ea194733d21e67dd2ba1fd (patch)
tree072d22a5d030d425c8f5d02a4912514ec2714763
parent7ddae82e12593ff3d44e628c02fbfa765508aa48 (diff)
drm/msm: Fix NULL deref in adreno_load_gpu
The msm/kms driver should work even if there is no GPU device specified in DT. Currently, we get a NULL dereference crash in adreno_load_gpu since the driver assumes that priv->gpu_pdev is non-NULL. Perform an additional check on priv->gpu_pdev before trying to retrieve the msm_gpu pointer from it. v2: Incorporate Jordan's comments: - Simplify the check to share the same error message. - Use dev_err_once() to avoid an error message every time we open the drm device fd. Fixes: eec874ce5ff1 (drm/msm/adreno: load gpu at probe/bind time) Signed-off-by: Archit Taneja <architt@codeaurora.org> Acked-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Rob Clark <robdclark@gmail.com>
-rw-r--r--drivers/gpu/drm/msm/adreno/adreno_device.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c
index ef4baa919135..c30bd24bc92c 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_device.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_device.c
@@ -130,11 +130,14 @@ struct msm_gpu *adreno_load_gpu(struct drm_device *dev)
130{ 130{
131 struct msm_drm_private *priv = dev->dev_private; 131 struct msm_drm_private *priv = dev->dev_private;
132 struct platform_device *pdev = priv->gpu_pdev; 132 struct platform_device *pdev = priv->gpu_pdev;
133 struct msm_gpu *gpu = platform_get_drvdata(priv->gpu_pdev); 133 struct msm_gpu *gpu = NULL;
134 int ret; 134 int ret;
135 135
136 if (pdev)
137 gpu = platform_get_drvdata(pdev);
138
136 if (!gpu) { 139 if (!gpu) {
137 dev_err(dev->dev, "no adreno device\n"); 140 dev_err_once(dev->dev, "no GPU device was found\n");
138 return NULL; 141 return NULL;
139 } 142 }
140 143