* [PATCH] drm/amdgpu: fix null pointer reference to adev.
@ 2020-07-07 3:26 Lepton Wu
2020-07-07 6:59 ` Christian König
0 siblings, 1 reply; 5+ messages in thread
From: Lepton Wu @ 2020-07-07 3:26 UTC (permalink / raw)
To: amd-gfx; +Cc: alexander.deucher, christian.koenig, 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.
Signed-off-by: Lepton Wu <ytht.net@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);
--
2.27.0.212.ge8ba1cc988-goog
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/amdgpu: fix null pointer reference to adev.
2020-07-07 3:26 [PATCH] drm/amdgpu: fix null pointer reference to adev Lepton Wu
@ 2020-07-07 6:59 ` Christian König
2020-07-07 18:04 ` [PATCH v2] " Lepton Wu
0 siblings, 1 reply; 5+ messages in thread
From: Christian König @ 2020-07-07 6:59 UTC (permalink / raw)
To: Lepton Wu, amd-gfx; +Cc: alexander.deucher
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@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);
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] drm/amdgpu: fix null pointer reference to adev.
2020-07-07 6:59 ` Christian König
@ 2020-07-07 18:04 ` Lepton Wu
2020-07-07 18:22 ` Alex Deucher
0 siblings, 1 reply; 5+ messages in thread
From: Lepton Wu @ 2020-07-07 18:04 UTC (permalink / raw)
To: amd-gfx; +Cc: alexander.deucher, christian.koenig, 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.
v2: Check return code of amdgpu_driver_load_kms
Signed-off-by: Lepton Wu <ytht.net@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 +++-
1 file changed, 3 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..75bcd1789185 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1111,7 +1111,9 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
pci_set_drvdata(pdev, dev);
- amdgpu_driver_load_kms(dev, ent->driver_data);
+ ret = amdgpu_driver_load_kms(dev, ent->driver_data);
+ if (ret)
+ goto err_pci;
retry_init:
ret = drm_dev_register(dev, ent->driver_data);
--
2.27.0.212.ge8ba1cc988-goog
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] drm/amdgpu: fix null pointer reference to adev.
2020-07-07 18:04 ` [PATCH v2] " Lepton Wu
@ 2020-07-07 18:22 ` Alex Deucher
2020-07-07 18:26 ` lepton
0 siblings, 1 reply; 5+ messages in thread
From: Alex Deucher @ 2020-07-07 18:22 UTC (permalink / raw)
To: Lepton Wu; +Cc: Deucher, Alexander, Christian Koenig, amd-gfx list
On Tue, Jul 7, 2020 at 2:15 PM Lepton Wu <ytht.net@gmail.com> wrote:
>
> 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.
>
> v2: Check return code of amdgpu_driver_load_kms
>
> Signed-off-by: Lepton Wu <ytht.net@gmail.com>
Already fixed:
https://cgit.freedesktop.org/drm/drm/commit/?id=7504d3bbec7da70516a13e34415b92bf5203399a
Alex
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 +++-
> 1 file changed, 3 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..75bcd1789185 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> @@ -1111,7 +1111,9 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
>
> pci_set_drvdata(pdev, dev);
>
> - amdgpu_driver_load_kms(dev, ent->driver_data);
> + ret = amdgpu_driver_load_kms(dev, ent->driver_data);
> + if (ret)
> + goto err_pci;
>
> retry_init:
> ret = drm_dev_register(dev, ent->driver_data);
> --
> 2.27.0.212.ge8ba1cc988-goog
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] drm/amdgpu: fix null pointer reference to adev.
2020-07-07 18:22 ` Alex Deucher
@ 2020-07-07 18:26 ` lepton
0 siblings, 0 replies; 5+ messages in thread
From: lepton @ 2020-07-07 18:26 UTC (permalink / raw)
To: Alex Deucher; +Cc: Deucher, Alexander, Christian Koenig, amd-gfx list
On Tue, Jul 7, 2020 at 11:22 AM Alex Deucher <alexdeucher@gmail.com> wrote:
>
> On Tue, Jul 7, 2020 at 2:15 PM Lepton Wu <ytht.net@gmail.com> wrote:
> >
> > 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.
> >
> > v2: Check return code of amdgpu_driver_load_kms
> >
> > Signed-off-by: Lepton Wu <ytht.net@gmail.com>
>
> Already fixed:
> https://cgit.freedesktop.org/drm/drm/commit/?id=7504d3bbec7da70516a13e34415b92bf5203399a
Nice, next time I will check drm tree instead of Linus tree for drm
related stuff.
>
> Alex
>
> > ---
> > drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 +++-
> > 1 file changed, 3 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..75bcd1789185 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> > @@ -1111,7 +1111,9 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
> >
> > pci_set_drvdata(pdev, dev);
> >
> > - amdgpu_driver_load_kms(dev, ent->driver_data);
> > + ret = amdgpu_driver_load_kms(dev, ent->driver_data);
> > + if (ret)
> > + goto err_pci;
> >
> > retry_init:
> > ret = drm_dev_register(dev, ent->driver_data);
> > --
> > 2.27.0.212.ge8ba1cc988-goog
> >
> > _______________________________________________
> > amd-gfx mailing list
> > amd-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-07-07 18:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-07 3:26 [PATCH] drm/amdgpu: fix null pointer reference to adev Lepton Wu
2020-07-07 6:59 ` Christian König
2020-07-07 18:04 ` [PATCH v2] " Lepton Wu
2020-07-07 18:22 ` Alex Deucher
2020-07-07 18:26 ` lepton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.