[PATCH] drm/amdgpu: fix null pointer reference to adev.
Christian König
christian.koenig at amd.com
Tue Jul 7 06:59:12 UTC 2020
Am 07.07.20 um 05:26 schrieb Lepton Wu:
> I hit this when compiling amdgpu in kernel. amdgpu_driver_load_kms fail
> to load firmwares since GPU was initialized before rootfs is ready.
> Just gracefully fail in such cases.
Good catch, but the solution looks incorrect to me.
The underlying problem is that the return value of
amdgpu_driver_load_kms() is not correctly checked.
Christian.
>
> Signed-off-by: Lepton Wu <ytht.net at gmail.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++-
> drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 2 ++
> 2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> index 126e74758a34..f9d277f8ddd4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> @@ -1124,7 +1124,8 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
> goto err_pci;
>
> adev = dev->dev_private;
> - ret = amdgpu_debugfs_init(adev);
> + if (adev)
> + ret = amdgpu_debugfs_init(adev);
> if (ret)
> DRM_ERROR("Creating debugfs files failed (%d).\n", ret);
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index d7e17e34fee1..99a6ec49ead5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -978,6 +978,8 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
> struct amdgpu_fpriv *fpriv;
> int r, pasid;
>
> + if (!adev)
> + return -ENODEV;
> /* Ensure IB tests are run on ring */
> flush_delayed_work(&adev->delayed_init_work);
>
More information about the amd-gfx
mailing list