drm/amd/display - Don't leak memory when updating streams
Subsystems (3)
PATCH 1/1 drm/amd/display - Don't leak memory when updating streams
[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.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +7 -1
@@ -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); }/*
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20190128140052.17217-1-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org
Li, Sun peng (Leo)
Reviewed-by Leo LiQuoted 8 lines · 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.
Quoted 7 lines
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 <[email protected]>Cc Leo Li <[email protected]>Cc Harry Wentland <[email protected]>Signed-off-by Nicholas Kazlauskas <[email protected]>
Thanks!
Quoted 22 lines
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3
-1@@ -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) {
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, · line 4996
Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4
-0@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Michel Dänzer
Tested-byQuoted 8 lines · 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.
Quoted 7 lines
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 <[email protected]>Cc Leo Li <[email protected]>Cc Harry Wentland <[email protected]>Signed-off-by Nicholas Kazlauskas <[email protected]>
Thanks Nicholas!
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Wentland, Harry
Reviewed-by Harry WentlandQuoted 8 lines · 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.
Quoted 7 lines
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 <[email protected]>Cc Leo Li <[email protected]>Cc Harry Wentland <[email protected]>Signed-off-by Nicholas Kazlauskas <[email protected]>
Harry
Quoted 22 lines
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3
-1@@ -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) {
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, · line 4996
Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4
-0@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx