Skip to contentSkip to conversation

drm/amd/display - Don't leak memory when updating streams

PATCH In review Nicholas Kazlauskas 4 participants 4 messages Jan 28, 2019 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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.

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]>
---
 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
index e551183784fb..78c89da47a33 100644
@@ -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

Reviewed-by Leo Li
#2 lore raw
Quoted 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]>

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
index e551183784fb..78c89da47a33 100644
@@ -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

Tested-by
#3 lore raw
In reply to a message not in the archive
Quoted 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]>

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
Reviewed-by Harry Wentland
#4 lore raw
In reply to a message not in the archive
Quoted 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]>

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
index e551183784fb..78c89da47a33 100644
@@ -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