All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/radeon: fix error handling in radeon_driver_open_kms
@ 2022-01-17  9:38 Christian König
  2022-01-17  9:58 ` Jan Stancek
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Christian König @ 2022-01-17  9:38 UTC (permalink / raw)
  To: bp, jstancek, arthur.marsh; +Cc: amd-gfx

The return value was never initialized so the cleanup code executed when
it isn't even necessary.

Just add proper error handling.

Fixes: 2ad5d8fca195 ("drm/radeon/radeon_kms: Fix a NULL pointer dereference in radeon_driver_open_kms()")
Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/radeon/radeon_kms.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index e2488559cc9f..11ad210919c8 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -666,18 +666,18 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
 		fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL);
 		if (unlikely(!fpriv)) {
 			r = -ENOMEM;
-			goto out_suspend;
+			goto err_suspend;
 		}
 
 		if (rdev->accel_working) {
 			vm = &fpriv->vm;
 			r = radeon_vm_init(rdev, vm);
 			if (r)
-				goto out_fpriv;
+				goto err_fpriv;
 
 			r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false);
 			if (r)
-				goto out_vm_fini;
+				goto err_vm_fini;
 
 			/* map the ib pool buffer read only into
 			 * virtual address space */
@@ -685,7 +685,7 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
 							rdev->ring_tmp_bo.bo);
 			if (!vm->ib_bo_va) {
 				r = -ENOMEM;
-				goto out_vm_fini;
+				goto err_vm_fini;
 			}
 
 			r = radeon_vm_bo_set_addr(rdev, vm->ib_bo_va,
@@ -693,19 +693,21 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
 						  RADEON_VM_PAGE_READABLE |
 						  RADEON_VM_PAGE_SNOOPED);
 			if (r)
-				goto out_vm_fini;
+				goto err_vm_fini;
 		}
 		file_priv->driver_priv = fpriv;
 	}
 
-	if (!r)
-		goto out_suspend;
+	pm_runtime_mark_last_busy(dev->dev);
+	pm_runtime_put_autosuspend(dev->dev);
+	return 0;
 
-out_vm_fini:
+err_vm_fini:
 	radeon_vm_fini(rdev, vm);
-out_fpriv:
+err_fpriv:
 	kfree(fpriv);
-out_suspend:
+
+err_suspend:
 	pm_runtime_mark_last_busy(dev->dev);
 	pm_runtime_put_autosuspend(dev->dev);
 	return r;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/radeon: fix error handling in radeon_driver_open_kms
  2022-01-17  9:38 [PATCH] drm/radeon: fix error handling in radeon_driver_open_kms Christian König
@ 2022-01-17  9:58 ` Jan Stancek
  2022-01-17 11:34 ` Borislav Petkov
  2022-01-17 18:55 ` Alex Deucher
  2 siblings, 0 replies; 4+ messages in thread
From: Jan Stancek @ 2022-01-17  9:58 UTC (permalink / raw)
  To: Christian König; +Cc: arthur.marsh, bp, amd-gfx

On Mon, Jan 17, 2022 at 10:38 AM Christian König
<ckoenig.leichtzumerken@gmail.com> wrote:
>
> The return value was never initialized so the cleanup code executed when
> it isn't even necessary.
>
> Just add proper error handling.
>
> Fixes: 2ad5d8fca195 ("drm/radeon/radeon_kms: Fix a NULL pointer dereference in radeon_driver_open_kms()")
> Signed-off-by: Christian König <christian.koenig@amd.com>

Thanks for quick patch, applied on top of 8d0749b4f83b Merge tag
'drm-next-2022-01-07'
it fixed the boot panic for me.

Tested-by: Jan Stancek <jstancek@redhat.com>

> ---
>  drivers/gpu/drm/radeon/radeon_kms.c | 22 ++++++++++++----------
>  1 file changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
> index e2488559cc9f..11ad210919c8 100644
> --- a/drivers/gpu/drm/radeon/radeon_kms.c
> +++ b/drivers/gpu/drm/radeon/radeon_kms.c
> @@ -666,18 +666,18 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
>                 fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL);
>                 if (unlikely(!fpriv)) {
>                         r = -ENOMEM;
> -                       goto out_suspend;
> +                       goto err_suspend;
>                 }
>
>                 if (rdev->accel_working) {
>                         vm = &fpriv->vm;
>                         r = radeon_vm_init(rdev, vm);
>                         if (r)
> -                               goto out_fpriv;
> +                               goto err_fpriv;
>
>                         r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false);
>                         if (r)
> -                               goto out_vm_fini;
> +                               goto err_vm_fini;
>
>                         /* map the ib pool buffer read only into
>                          * virtual address space */
> @@ -685,7 +685,7 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
>                                                         rdev->ring_tmp_bo.bo);
>                         if (!vm->ib_bo_va) {
>                                 r = -ENOMEM;
> -                               goto out_vm_fini;
> +                               goto err_vm_fini;
>                         }
>
>                         r = radeon_vm_bo_set_addr(rdev, vm->ib_bo_va,
> @@ -693,19 +693,21 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
>                                                   RADEON_VM_PAGE_READABLE |
>                                                   RADEON_VM_PAGE_SNOOPED);
>                         if (r)
> -                               goto out_vm_fini;
> +                               goto err_vm_fini;
>                 }
>                 file_priv->driver_priv = fpriv;
>         }
>
> -       if (!r)
> -               goto out_suspend;
> +       pm_runtime_mark_last_busy(dev->dev);
> +       pm_runtime_put_autosuspend(dev->dev);
> +       return 0;
>
> -out_vm_fini:
> +err_vm_fini:
>         radeon_vm_fini(rdev, vm);
> -out_fpriv:
> +err_fpriv:
>         kfree(fpriv);
> -out_suspend:
> +
> +err_suspend:
>         pm_runtime_mark_last_busy(dev->dev);
>         pm_runtime_put_autosuspend(dev->dev);
>         return r;
> --
> 2.25.1
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/radeon: fix error handling in radeon_driver_open_kms
  2022-01-17  9:38 [PATCH] drm/radeon: fix error handling in radeon_driver_open_kms Christian König
  2022-01-17  9:58 ` Jan Stancek
@ 2022-01-17 11:34 ` Borislav Petkov
  2022-01-17 18:55 ` Alex Deucher
  2 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2022-01-17 11:34 UTC (permalink / raw)
  To: Christian König; +Cc: arthur.marsh, jstancek, amd-gfx

On Mon, Jan 17, 2022 at 10:38:48AM +0100, Christian König wrote:
> The return value was never initialized so the cleanup code executed when
> it isn't even necessary.
> 
> Just add proper error handling.
> 
> Fixes: 2ad5d8fca195 ("drm/radeon/radeon_kms: Fix a NULL pointer dereference in radeon_driver_open_kms()")
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>  drivers/gpu/drm/radeon/radeon_kms.c | 22 ++++++++++++----------
>  1 file changed, 12 insertions(+), 10 deletions(-)

Looks good, box boots fine with it.

Tested-by: Borislav Petkov <bp@suse.de>

Thx!

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/radeon: fix error handling in radeon_driver_open_kms
  2022-01-17  9:38 [PATCH] drm/radeon: fix error handling in radeon_driver_open_kms Christian König
  2022-01-17  9:58 ` Jan Stancek
  2022-01-17 11:34 ` Borislav Petkov
@ 2022-01-17 18:55 ` Alex Deucher
  2 siblings, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2022-01-17 18:55 UTC (permalink / raw)
  To: Christian König
  Cc: arthur.marsh, Borislav Petkov, jstancek, amd-gfx list

On Mon, Jan 17, 2022 at 4:38 AM Christian König
<ckoenig.leichtzumerken@gmail.com> wrote:
>
> The return value was never initialized so the cleanup code executed when
> it isn't even necessary.
>
> Just add proper error handling.
>
> Fixes: 2ad5d8fca195 ("drm/radeon/radeon_kms: Fix a NULL pointer dereference in radeon_driver_open_kms()")
> Signed-off-by: Christian König <christian.koenig@amd.com>

If you kept the same labels, the patch would be smaller, but either way,

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/radeon/radeon_kms.c | 22 ++++++++++++----------
>  1 file changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
> index e2488559cc9f..11ad210919c8 100644
> --- a/drivers/gpu/drm/radeon/radeon_kms.c
> +++ b/drivers/gpu/drm/radeon/radeon_kms.c
> @@ -666,18 +666,18 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
>                 fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL);
>                 if (unlikely(!fpriv)) {
>                         r = -ENOMEM;
> -                       goto out_suspend;
> +                       goto err_suspend;
>                 }
>
>                 if (rdev->accel_working) {
>                         vm = &fpriv->vm;
>                         r = radeon_vm_init(rdev, vm);
>                         if (r)
> -                               goto out_fpriv;
> +                               goto err_fpriv;
>
>                         r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false);
>                         if (r)
> -                               goto out_vm_fini;
> +                               goto err_vm_fini;
>
>                         /* map the ib pool buffer read only into
>                          * virtual address space */
> @@ -685,7 +685,7 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
>                                                         rdev->ring_tmp_bo.bo);
>                         if (!vm->ib_bo_va) {
>                                 r = -ENOMEM;
> -                               goto out_vm_fini;
> +                               goto err_vm_fini;
>                         }
>
>                         r = radeon_vm_bo_set_addr(rdev, vm->ib_bo_va,
> @@ -693,19 +693,21 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
>                                                   RADEON_VM_PAGE_READABLE |
>                                                   RADEON_VM_PAGE_SNOOPED);
>                         if (r)
> -                               goto out_vm_fini;
> +                               goto err_vm_fini;
>                 }
>                 file_priv->driver_priv = fpriv;
>         }
>
> -       if (!r)
> -               goto out_suspend;
> +       pm_runtime_mark_last_busy(dev->dev);
> +       pm_runtime_put_autosuspend(dev->dev);
> +       return 0;
>
> -out_vm_fini:
> +err_vm_fini:
>         radeon_vm_fini(rdev, vm);
> -out_fpriv:
> +err_fpriv:
>         kfree(fpriv);
> -out_suspend:
> +
> +err_suspend:
>         pm_runtime_mark_last_busy(dev->dev);
>         pm_runtime_put_autosuspend(dev->dev);
>         return r;
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-17 18:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-17  9:38 [PATCH] drm/radeon: fix error handling in radeon_driver_open_kms Christian König
2022-01-17  9:58 ` Jan Stancek
2022-01-17 11:34 ` Borislav Petkov
2022-01-17 18:55 ` Alex Deucher

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.