diff mbox

[1/2] drm/amdgpu: Fix memory leaks at amdgpu_init() error path

Message ID 20180330204512.16863-1-tiwai@suse.de (mailing list archive)
State New, archived
Headers show

Commit Message

Takashi Iwai March 30, 2018, 8:45 p.m. UTC
amdgpu driver checks vgacon_text_force() after some initializations
but without cleaning up.  This will result in leaks.

Move the check of vgacon_text_force() to the beginning of
amdgpu_init() for fixing it and also for optimization.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Alex Deucher April 2, 2018, 5:36 p.m. UTC | #1
On Fri, Mar 30, 2018 at 4:45 PM, Takashi Iwai <tiwai@suse.de> wrote:
> amdgpu driver checks vgacon_text_force() after some initializations
> but without cleaning up.  This will result in leaks.
>
> Move the check of vgacon_text_force() to the beginning of
> amdgpu_init() for fixing it and also for optimization.
>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>

Applied.  Thanks!

Alex

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> index 50afcf65181a..e55792d3cd12 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> @@ -905,6 +905,11 @@ static int __init amdgpu_init(void)
>  {
>         int r;
>
> +       if (vgacon_text_force()) {
> +               DRM_ERROR("VGACON disables amdgpu kernel modesetting.\n");
> +               return -EINVAL;
> +       }
> +
>         r = amdgpu_sync_init();
>         if (r)
>                 goto error_sync;
> @@ -913,10 +918,6 @@ static int __init amdgpu_init(void)
>         if (r)
>                 goto error_fence;
>
> -       if (vgacon_text_force()) {
> -               DRM_ERROR("VGACON disables amdgpu kernel modesetting.\n");
> -               return -EINVAL;
> -       }
>         DRM_INFO("amdgpu kernel modesetting enabled.\n");
>         driver = &kms_driver;
>         pdriver = &amdgpu_kms_pci_driver;
> --
> 2.16.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 50afcf65181a..e55792d3cd12 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -905,6 +905,11 @@  static int __init amdgpu_init(void)
 {
 	int r;
 
+	if (vgacon_text_force()) {
+		DRM_ERROR("VGACON disables amdgpu kernel modesetting.\n");
+		return -EINVAL;
+	}
+
 	r = amdgpu_sync_init();
 	if (r)
 		goto error_sync;
@@ -913,10 +918,6 @@  static int __init amdgpu_init(void)
 	if (r)
 		goto error_fence;
 
-	if (vgacon_text_force()) {
-		DRM_ERROR("VGACON disables amdgpu kernel modesetting.\n");
-		return -EINVAL;
-	}
 	DRM_INFO("amdgpu kernel modesetting enabled.\n");
 	driver = &kms_driver;
 	pdriver = &amdgpu_kms_pci_driver;