Skip to content

Commit c548830

Browse files
author
Russell King
committed
drm/armada: fix page_flip refcounting leak
A refcounting leak was found of the original frame buffer attached to the CRTC when using the page_flip ioctl, resulting in the frame buffer never being freed. This was not obvious initially, as if the page flip subsequently re-attaches the original frame buffer, the refcounts will be balanced. However, if the original frame buffer is freed, then it will be leaked. Fix this by ensuring that we take a reference on the incoming fb, but rely on the queued work to drop that ref count. Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent 0544e38 commit c548830

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

‎drivers/gpu/drm/armada/armada_crtc.c‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -945,18 +945,15 @@ static int armada_drm_crtc_page_flip(struct drm_crtc *crtc,
945945
armada_reg_queue_end(work->regs, i);
946946

947947
/*
948-
* Hold the old framebuffer for the work - DRM appears to drop our
949-
* reference to the old framebuffer in drm_mode_page_flip_ioctl().
948+
* Ensure that we hold a reference on the new framebuffer.
949+
* This has to match the behaviour in mode_set.
950950
*/
951-
drm_framebuffer_reference(work->old_fb);
951+
drm_framebuffer_reference(fb);
952952

953953
ret = armada_drm_crtc_queue_frame_work(dcrtc, work);
954954
if (ret) {
955-
/*
956-
* Undo our reference above; DRM does not drop the reference
957-
* to this object on error, so that's okay.
958-
*/
959-
drm_framebuffer_unreference(work->old_fb);
955+
/* Undo our reference above */
956+
drm_framebuffer_unreference(fb);
960957
kfree(work);
961958
return ret;
962959
}

0 commit comments

Comments
 (0)