On 11/21/2025 7:05 PM, Dan Carpenter wrote:
> Hello Akhil P Oommen,
>
> This is a semi-automatic email about new static checker warnings.
>
> Commit 491fadb2b818 ("drm/msm/adreno: Move adreno_gpu_func to
> catalogue") from Nov 18, 2025, leads to the following Smatch
> complaint:
>
> drivers/gpu/drm/msm/adreno/a3xx_gpu.c:530 a3xx_gpu_init() warn: variable
> dereferenced before check 'pdev' (see line 525)
> drivers/gpu/drm/msm/adreno/a4xx_gpu.c:642 a4xx_gpu_init() warn: variable
> dereferenced before check 'pdev' (see line 637)
> drivers/gpu/drm/msm/adreno/a2xx_gpu.c:503 a2xx_gpu_init() warn: variable
> dereferenced before check 'pdev' (see line 500)
>
> drivers/gpu/drm/msm/adreno/a3xx_gpu.c
> 524 struct platform_device *pdev = priv->gpu_pdev;
> 525 struct adreno_platform_config *config =
> pdev->dev.platform_data;
> ^^^^^^
> The patch adds a new unchecked dereference.
>
> 526 struct icc_path *ocmem_icc_path;
> 527 struct icc_path *icc_path;
> 528 int ret;
> 529
> 530 if (!pdev) {
> ^^^^^
> But the old code assumed pdev could be NULL.
>
> 531 DRM_DEV_ERROR(dev->dev, "no a3xx device\n");
> 532 ret = -ENXIO;
I looked up the history of this NULL check here and it looks like this
is present from the very first commit that added a3xx gpu support. In
that patch, pdev is assigned from a static variable which could be
potentially NULL.
But that is not the case now. gpu_pdev is updated from the parent fn
(adreno_bind()), so it cannot be NULL at this point. We can remove this
NULL check. I will send a patch.
-Akhil
>
> regards,
> dan carpenter