[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20230627041250.3899791-1-harshit.m.mogalapalli@oracle.com>
Date: Mon, 26 Jun 2023 21:12:35 -0700
From: Harshit Mogalapalli <harshit.m.mogalapalli@...cle.com>
To: unlisted-recipients:; (no To-header on input)
Cc: harshit.m.mogalapalli@...cle.com, error27@...il.com,
dan.carpenter@...aro.org, kernel-janitors@...r.kernel.org,
Rob Clark <robdclark@...il.com>,
Abhinav Kumar <quic_abhinavk@...cinc.com>,
Dmitry Baryshkov <dmitry.baryshkov@...aro.org>,
Sean Paul <sean@...rly.run>,
Marijn Suijten <marijn.suijten@...ainline.org>,
David Airlie <airlied@...il.com>,
Daniel Vetter <daniel@...ll.ch>,
Mukesh Ojha <quic_mojha@...cinc.com>,
Douglas Anderson <dianders@...omium.org>,
Akhil P Oommen <quic_akhilpo@...cinc.com>,
Adam Skladowski <a39.skl@...il.com>,
Elliot Berman <quic_eberman@...cinc.com>,
linux-arm-msm@...r.kernel.org, dri-devel@...ts.freedesktop.org,
freedreno@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: [PATCH next] drm/msm/a5xx: Fix a NULL dereference bug in a5xx_gpu_init()
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@...cle.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(-)
diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
index a99310b68793..adaf8f8e7f2d 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
@@ -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);
--
2.39.3
Powered by blists - more mailing lists