dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amd/display: Fix memleak in amdgpu_dm_mode_config_init
@ 2020-08-26 13:24 Dinghao Liu
  2020-08-26 13:45 ` Alex Deucher
  0 siblings, 1 reply; 2+ messages in thread
From: Dinghao Liu @ 2020-08-26 13:24 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: Stylon Wang, Leo Li, Bhawanpreet Lakha, Rodrigo Siqueira,
	Roman Li, amd-gfx, Nicholas Kazlauskas, David Airlie, dri-devel,
	Alex Deucher, Mikita Lipski, Christian König, linux-kernel

When amdgpu_display_modeset_create_props() fails, state and
state->context should be freed to prevent memleak. It's the
same when amdgpu_dm_audio_init() fails.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index df9338257ae0..2476e40c67ef 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -2834,12 +2834,18 @@ static int amdgpu_dm_mode_config_init(struct amdgpu_device *adev)
 				    &dm_atomic_state_funcs);
 
 	r = amdgpu_display_modeset_create_props(adev);
-	if (r)
+	if (r) {
+		dc_release_state(state->context);
+		kfree(state);
 		return r;
+	}
 
 	r = amdgpu_dm_audio_init(adev);
-	if (r)
+	if (r) {
+		dc_release_state(state->context);
+		kfree(state);
 		return r;
+	}
 
 	return 0;
 }
-- 
2.17.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm/amd/display: Fix memleak in amdgpu_dm_mode_config_init
  2020-08-26 13:24 [PATCH] drm/amd/display: Fix memleak in amdgpu_dm_mode_config_init Dinghao Liu
@ 2020-08-26 13:45 ` Alex Deucher
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Deucher @ 2020-08-26 13:45 UTC (permalink / raw)
  To: Dinghao Liu
  Cc: Stylon Wang, Leo Li, Kangjie Lu, Rodrigo Siqueira, Roman Li,
	amd-gfx list, Christian König, David Airlie,
	Maling list - DRI developers, Alex Deucher, Mikita Lipski,
	Bhawanpreet Lakha, Nicholas Kazlauskas, LKML

Applied.  Thanks!

Alex

On Wed, Aug 26, 2020 at 9:37 AM Dinghao Liu <dinghao.liu@zju.edu.cn> wrote:
>
> When amdgpu_display_modeset_create_props() fails, state and
> state->context should be freed to prevent memleak. It's the
> same when amdgpu_dm_audio_init() fails.
>
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index df9338257ae0..2476e40c67ef 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -2834,12 +2834,18 @@ static int amdgpu_dm_mode_config_init(struct amdgpu_device *adev)
>                                     &dm_atomic_state_funcs);
>
>         r = amdgpu_display_modeset_create_props(adev);
> -       if (r)
> +       if (r) {
> +               dc_release_state(state->context);
> +               kfree(state);
>                 return r;
> +       }
>
>         r = amdgpu_dm_audio_init(adev);
> -       if (r)
> +       if (r) {
> +               dc_release_state(state->context);
> +               kfree(state);
>                 return r;
> +       }
>
>         return 0;
>  }
> --
> 2.17.1
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2020-08-27  6:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-26 13:24 [PATCH] drm/amd/display: Fix memleak in amdgpu_dm_mode_config_init Dinghao Liu
2020-08-26 13:45 ` Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).