drm/msm: dpu: Fix memory leak caused by dropped reference
PATCH 1/2 drm/msm: dpu: Fix memory leak caused by dropped reference
From: Sean Paul <[email protected]>
We are currently leaking a drm_crtc_commit struct for every atomic commit containing plane state. The dpu plane destroy function cleans up the fb reference manually, but fails to release the commit ref. As a result, we just keep allocating drm_crtc_commits without ever freeing them. Fortunately there's a helper function which will clean up all of our mess at once, so use that.
Thanks to Doug Anderson for reporting the memory leak (and leaving breadcrumbs from kmemleak!).
--- drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +1 -3
@@ -1203,9 +1203,7 @@ static void dpu_plane_destroy_state(struct drm_plane *plane, pstate =to_dpu_plane_state (state); -/* remove ref count for frame buffers */ -if (state->fb) -drm_framebuffer_put (state->fb); +__drm_atomic_helper_plane_destroy_state (state);kfree (pstate); }
Signature · 6 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
A message that is not in the archive (sent off-list or not yet received): 20181004180945.46132-1-sean-p7yTbzM4H96eqtR555YLDQ@public.gmane.org
PATCH 2/2 drm/msm: dpu: Remove checks from dpu_plane_destroy_state()
From: Sean Paul <[email protected]>
They're not needed.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +1 -12
@@ -1193,19 +1193,8 @@ static void dpu_plane_destroy(struct drm_plane *plane)static void dpu_plane_destroy_state (struct drm_plane *plane,struct drm_plane_state *state) { -struct dpu_plane_state *pstate; - -if (!plane || !state) { -DPU_ERROR ("invalid arg(s), plane %d state %d\n" , - plane !=0 , state !=0 ); -return ; - } - - pstate =to_dpu_plane_state (state); -__drm_atomic_helper_plane_destroy_state (state); - -kfree (pstate); +kfree (to_dpu_plane_state (state)); } static struct drm_plane_state *
Signature · 6 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
A message that is not in the archive (sent off-list or not yet received): 20181004180945.46132-2-sean-p7yTbzM4H96eqtR555YLDQ@public.gmane.org
Jeykumar Sankaran
Reviewed-byRe: [PATCH 2/2] drm/msm: dpu: Remove checks from dpu_plane_destroy_state()
Quoted 6 lines · Sean Paul
From: Sean Paul <[email protected]>
They're not needed.
Signed-off-by Sean Paul <[email protected]>---
Quoted 30 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +1
-12@@ -1193,19 +1193,8 @@ static void dpu_plane_destroy(struct drm_plane *plane)static void dpu_plane_destroy_state (struct drm_plane *plane,struct drm_plane_state *state) { -struct dpu_plane_state *pstate; - -if (!plane || !state) { -DPU_ERROR ("invalid arg(s), plane %d state %d\n" , - plane !=0 , state !=0 ); -return ; - } - - pstate =to_dpu_plane_state (state); -__drm_atomic_helper_plane_destroy_state (state); - -kfree (pstate); +kfree (to_dpu_plane_state (state)); }static struct
drm_plane_state*
Signature · 5 lines
Jeykumar S _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
Jeykumar Sankaran
Reviewed-byQuoted 4 lines · Sean Paul
From: Sean Paul <[email protected]>
We are currently leaking a
drm_crtc_commitstruct for every atomic commit containing plane state. The dpu plane destroy function cleans up
dpu plane destroy -> dpu_plane_destroy_state
Quoted 11 lines
the fb reference manually, but fails to release the commit ref. As a result, we just keep allocating
drm_crtc_commitswithout ever freeing them. Fortunately there's a helper function which will clean up all of our mess at once, so use that.Thanks to Doug Anderson for reporting the memory leak (and leaving breadcrumbs from kmemleak!).
Reported-by Doug Anderson <[email protected]>Signed-off-by Sean Paul <[email protected]>---
With the nit addressed:
Quoted 21 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +0
-0@@ -1203,9 +1203,7 @@ static void dpu_plane_destroy_state(struct
drm_plane
*plane,drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +1
-3pstate =to_dpu_plane_state (state); -/* remove ref count for frame buffers */ -if (state->fb) -drm_framebuffer_put (state->fb); +__drm_atomic_helper_plane_destroy_state (state);kfree (pstate); }
Signature · 5 lines
Jeykumar S _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
A message that is not in the archive (sent off-list or not yet received): 97dcf11ad4358eb4bf198048602da801-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org
Quoted 11 lines · Jeykumar Sankaran
Quoted 4 lines · Sean Paul
From: Sean Paul <[email protected]>
We are currently leaking a
drm_crtc_commitstruct for every atomic commit containing plane state. The dpu plane destroy function cleans updpu plane destroy ->
dpu_plane_destroy_stateQuoted 5 lines
the fb reference manually, but fails to release the commit ref. As a result, we just keep allocating
drm_crtc_commitswithout ever freeing them. Fortunately there's a helper function which will clean up all of our mess at once, so use that.
Quoted 7 lines
Quoted 6 lines
Thanks to Doug Anderson for reporting the memory leak (and leaving breadcrumbs from kmemleak!).
Reported-by Doug Anderson <[email protected]>Signed-off-by Sean Paul <[email protected]>---
With the nit addressed:
FYI, this already picked up in msm-next last week.
Quoted 27 lines
Reviewed-by Jeykumar Sankaran <[email protected]>Quoted 21 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +0
-0@@ -1203,9 +1203,7 @@ static void dpu_plane_destroy_state(struct
drm_plane
*plane,drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +1
-3pstate =to_dpu_plane_state (state); -/* remove ref count for frame buffers */ -if (state->fb) -drm_framebuffer_put (state->fb); +__drm_atomic_helper_plane_destroy_state (state);kfree (pstate); }Signature · 1 line
Jeykumar S
Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno