* [PATCH] drm/msm/a5xx: Fix dereference of pointer pdev before null check on pdev
@ 2024-11-12 13:20 Colin Ian King
2024-11-12 15:28 ` Konrad Dybcio
0 siblings, 1 reply; 2+ messages in thread
From: Colin Ian King @ 2024-11-12 13:20 UTC (permalink / raw)
To: Rob Clark, Sean Paul, Konrad Dybcio, Abhinav Kumar,
Dmitry Baryshkov, Marijn Suijten, David Airlie, Simona Vetter,
linux-arm-msm, dri-devel, freedreno
Cc: kernel-janitors, linux-kernel
The pointer config is dereferencing pointer pdev before pdev is null
checked, this could lead to a potential null pointer dereference on pdev.
Fix this by only assinging config after pdev has been null checked.
Fixes: 736a93273656 ("drm/msm/a5xx: really check for A510 in a5xx_gpu_init")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
index ee89db72e36e..e83081346059 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
@@ -1753,7 +1753,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;
@@ -1764,6 +1764,7 @@ struct msm_gpu *a5xx_gpu_init(struct drm_device *dev)
DRM_DEV_ERROR(dev->dev, "No A5XX device is defined\n");
return ERR_PTR(-ENXIO);
}
+ config = pdev->dev.platform_data;
a5xx_gpu = kzalloc(sizeof(*a5xx_gpu), GFP_KERNEL);
if (!a5xx_gpu)
--
2.39.5
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] drm/msm/a5xx: Fix dereference of pointer pdev before null check on pdev
2024-11-12 13:20 [PATCH] drm/msm/a5xx: Fix dereference of pointer pdev before null check on pdev Colin Ian King
@ 2024-11-12 15:28 ` Konrad Dybcio
0 siblings, 0 replies; 2+ messages in thread
From: Konrad Dybcio @ 2024-11-12 15:28 UTC (permalink / raw)
To: Colin Ian King, Rob Clark, Sean Paul, Konrad Dybcio,
Abhinav Kumar, Dmitry Baryshkov, Marijn Suijten, David Airlie,
Simona Vetter, linux-arm-msm, dri-devel, freedreno
Cc: kernel-janitors, linux-kernel
On 11/12/24 14:20, Colin Ian King wrote:
> The pointer config is dereferencing pointer pdev before pdev is null
> checked, this could lead to a potential null pointer dereference on pdev.
> Fix this by only assinging config after pdev has been null checked.
>
> Fixes: 736a93273656 ("drm/msm/a5xx: really check for A510 in a5xx_gpu_init")
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
I'd rather drop this check, the only call chain is rather
safe here
Konrad
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-11-12 15:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-12 13:20 [PATCH] drm/msm/a5xx: Fix dereference of pointer pdev before null check on pdev Colin Ian King
2024-11-12 15:28 ` Konrad Dybcio
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox