[Freedreno] [bug report] drm/msm/a5xx: really check for A510 in a5xx_gpu_init

Dan Carpenter dan.carpenter at linaro.org
Thu Jun 15 06:12:02 UTC 2023


Hello Dmitry Baryshkov,

This is a semi-automatic email about new static checker warnings.

The patch 736a93273656: "drm/msm/a5xx: really check for A510 in
a5xx_gpu_init" from Apr 9, 2023, leads to the following Smatch
complaint:

    drivers/gpu/drm/msm/adreno/a5xx_gpu.c:1753 a5xx_gpu_init()
    warn: variable dereferenced before check 'pdev' (see line 1746)

drivers/gpu/drm/msm/adreno/a5xx_gpu.c
  1745		struct platform_device *pdev = priv->gpu_pdev;
  1746		struct adreno_platform_config *config = pdev->dev.platform_data;
                                                        ^^^^^^^
The patch adds an unchecked dereference

  1747		struct a5xx_gpu *a5xx_gpu = NULL;
  1748		struct adreno_gpu *adreno_gpu;
  1749		struct msm_gpu *gpu;
  1750		unsigned int nr_rings;
  1751		int ret;
  1752	
  1753		if (!pdev) {
                    ^^^^^
But the existing code assumes it can be NULL.  Do we really need this
check?

  1754			DRM_DEV_ERROR(dev->dev, "No A5XX device is defined\n");
  1755			return ERR_PTR(-ENXIO);

regards,
dan carpenter


More information about the Freedreno mailing list