* [PATCH] drm/amd/display - Don't leak memory when updating streams
@ 2019-01-28 14:00 Nicholas Kazlauskas
[not found] ` <20190128140052.17217-1-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Nicholas Kazlauskas @ 2019-01-28 14:00 UTC (permalink / raw)
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Cc: Leo Li, Michel Dänzer, Harry Wentland, Nicholas Kazlauskas
[Why]
The flip and full structures were allocated but never freed.
[How]
Free them at the end of the function. There's a small behavioral
change here with the function returning early if the allocation fails
but we wouldn't should be doing anything in that case anyway.
Fixes: c00e0cc0fdc0 ("drm/amd/display: Call into DC once per multiplane flip")
Fixes: ea39594e0855 ("drm/amd/display: Perform plane updates only when needed")
Cc: Michel Dänzer <michel@daenzer.net>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Harry Wentland <Harry.Wentland@amd.com>
Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
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 e551183784fb..78c89da47a33 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4760,8 +4760,10 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
flip = kzalloc(sizeof(*flip), GFP_KERNEL);
full = kzalloc(sizeof(*full), GFP_KERNEL);
- if (!flip || !full)
+ if (!flip || !full) {
dm_error("Failed to allocate update bundles\n");
+ goto cleanup;
+ }
/* update planes when needed */
for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
@@ -4985,6 +4987,10 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
dc_state);
mutex_unlock(&dm->dc_lock);
}
+
+cleanup:
+ kfree(flip);
+ kfree(full);
}
/*
--
2.17.1
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/amd/display - Don't leak memory when updating streams
[not found] ` <20190128140052.17217-1-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
@ 2019-01-28 14:22 ` Li, Sun peng (Leo)
2019-01-28 15:14 ` Michel Dänzer
2019-01-28 16:33 ` Wentland, Harry
2 siblings, 0 replies; 4+ messages in thread
From: Li, Sun peng (Leo) @ 2019-01-28 14:22 UTC (permalink / raw)
To: Kazlauskas, Nicholas, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Cc: Michel Dänzer, Wentland, Harry
On 2019-01-28 9:00 a.m., Nicholas Kazlauskas wrote:
> [Why]
> The flip and full structures were allocated but never freed.
>
> [How]
> Free them at the end of the function. There's a small behavioral
> change here with the function returning early if the allocation fails
> but we wouldn't should be doing anything in that case anyway.
>
> Fixes: c00e0cc0fdc0 ("drm/amd/display: Call into DC once per multiplane flip")
> Fixes: ea39594e0855 ("drm/amd/display: Perform plane updates only when needed")
>
> Cc: Michel Dänzer <michel@daenzer.net>
> Cc: Leo Li <sunpeng.li@amd.com>
> Cc: Harry Wentland <Harry.Wentland@amd.com>
> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Reviewed-by: Leo Li <sunpeng.li@amd.com>
Thanks!
> ---
> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> 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 e551183784fb..78c89da47a33 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -4760,8 +4760,10 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
> flip = kzalloc(sizeof(*flip), GFP_KERNEL);
> full = kzalloc(sizeof(*full), GFP_KERNEL);
>
> - if (!flip || !full)
> + if (!flip || !full) {
> dm_error("Failed to allocate update bundles\n");
> + goto cleanup;
> + }
>
> /* update planes when needed */
> for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
> @@ -4985,6 +4987,10 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
> dc_state);
> mutex_unlock(&dm->dc_lock);
> }
> +
> +cleanup:
> + kfree(flip);
> + kfree(full);
> }
>
> /*
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/amd/display - Don't leak memory when updating streams
[not found] ` <20190128140052.17217-1-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
2019-01-28 14:22 ` Li, Sun peng (Leo)
@ 2019-01-28 15:14 ` Michel Dänzer
2019-01-28 16:33 ` Wentland, Harry
2 siblings, 0 replies; 4+ messages in thread
From: Michel Dänzer @ 2019-01-28 15:14 UTC (permalink / raw)
To: Nicholas Kazlauskas
Cc: Leo Li, Harry Wentland, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
On 2019-01-28 3:00 p.m., Nicholas Kazlauskas wrote:
> [Why]
> The flip and full structures were allocated but never freed.
>
> [How]
> Free them at the end of the function. There's a small behavioral
> change here with the function returning early if the allocation fails
> but we wouldn't should be doing anything in that case anyway.
>
> Fixes: c00e0cc0fdc0 ("drm/amd/display: Call into DC once per multiplane flip")
> Fixes: ea39594e0855 ("drm/amd/display: Perform plane updates only when needed")
>
> Cc: Michel Dänzer <michel@daenzer.net>
> Cc: Leo Li <sunpeng.li@amd.com>
> Cc: Harry Wentland <Harry.Wentland@amd.com>
> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Tested-by: Michel Dänzer <michel.daenzer@amd.com>
Thanks Nicholas!
--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/amd/display - Don't leak memory when updating streams
[not found] ` <20190128140052.17217-1-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
2019-01-28 14:22 ` Li, Sun peng (Leo)
2019-01-28 15:14 ` Michel Dänzer
@ 2019-01-28 16:33 ` Wentland, Harry
2 siblings, 0 replies; 4+ messages in thread
From: Wentland, Harry @ 2019-01-28 16:33 UTC (permalink / raw)
To: Kazlauskas, Nicholas, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Cc: Li, Sun peng (Leo), Michel Dänzer
On 2019-01-28 9:00 a.m., Nicholas Kazlauskas wrote:
> [Why]
> The flip and full structures were allocated but never freed.
>
> [How]
> Free them at the end of the function. There's a small behavioral
> change here with the function returning early if the allocation fails
> but we wouldn't should be doing anything in that case anyway.
>
> Fixes: c00e0cc0fdc0 ("drm/amd/display: Call into DC once per multiplane flip")
> Fixes: ea39594e0855 ("drm/amd/display: Perform plane updates only when needed")
>
> Cc: Michel Dänzer <michel@daenzer.net>
> Cc: Leo Li <sunpeng.li@amd.com>
> Cc: Harry Wentland <Harry.Wentland@amd.com>
> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Harry
> ---
> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> 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 e551183784fb..78c89da47a33 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -4760,8 +4760,10 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
> flip = kzalloc(sizeof(*flip), GFP_KERNEL);
> full = kzalloc(sizeof(*full), GFP_KERNEL);
>
> - if (!flip || !full)
> + if (!flip || !full) {
> dm_error("Failed to allocate update bundles\n");
> + goto cleanup;
> + }
>
> /* update planes when needed */
> for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
> @@ -4985,6 +4987,10 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
> dc_state);
> mutex_unlock(&dm->dc_lock);
> }
> +
> +cleanup:
> + kfree(flip);
> + kfree(full);
> }
>
> /*
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-01-28 16:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-28 14:00 [PATCH] drm/amd/display - Don't leak memory when updating streams Nicholas Kazlauskas
[not found] ` <20190128140052.17217-1-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
2019-01-28 14:22 ` Li, Sun peng (Leo)
2019-01-28 15:14 ` Michel Dänzer
2019-01-28 16:33 ` Wentland, Harry
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.