Increase reference count of FB assigned to drmmode_crtc->flip_pending
PATCH 1/1 Increase reference count of FB assigned to drmmode_crtc->flip_pending
From: Michel Dänzer <[email protected]>
Otherwise, it could happen that we destroy the FB before the flip completes, resulting in use-after-free and most likely a crash.
--- src/amdgpu_kms.c | 8 ++++---- src/drmmode_display.c | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-)
src/amdgpu_kms.c +4 -4
@@ -722,8 +722,8 @@ amdgpu_prime_scanout_flip(PixmapDirtyUpdatePtr ent)return ; } - drmmode_crtc->flip_pending = -amdgpu_pixmap_get_fb (drmmode_crtc->scanout[scanout_id].pixmap); +drmmode_fb_reference (pAMDGPUEnt->fd, &drmmode_crtc->flip_pending, +amdgpu_pixmap_get_fb (drmmode_crtc->scanout[scanout_id].pixmap));if (!drmmode_crtc->flip_pending) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"Failed to get FB for PRIME flip.\n" );
@@ -1011,8 +1011,8 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info,return ; } - drmmode_crtc->flip_pending = -amdgpu_pixmap_get_fb (drmmode_crtc->scanout[scanout_id].pixmap); +drmmode_fb_reference (pAMDGPUEnt->fd, &drmmode_crtc->flip_pending, +amdgpu_pixmap_get_fb (drmmode_crtc->scanout[scanout_id].pixmap));if (!drmmode_crtc->flip_pending) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"Failed to get FB for scanout flip.\n" );
src/drmmode_display.c +6 -2
@@ -2196,8 +2196,11 @@ void drmmode_clear_pending_flip(xf86CrtcPtr crtc) {drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; +ScrnInfoPtr scrn = crtc->scrn; +AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (scrn); - drmmode_crtc->flip_pending =NULL ; +drmmode_fb_reference (pAMDGPUEnt->fd, &drmmode_crtc->flip_pending, +NULL ); if (!crtc->enabled || (drmmode_crtc->pending_dpms_mode != DPMSModeOn &&
@@ -2835,7 +2838,8 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, goto flip_error; } - drmmode_crtc->flip_pending = fb; +drmmode_fb_reference (pAMDGPUEnt->fd, &drmmode_crtc->flip_pending, + fb); drm_queue_seq =0 ; }
Signature · 6 lines
2.11.0 _______________________________________________ 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): 20170622035532.3461-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org
Deucher, Alexander
Reviewed-by Alex DeucherQuoted 8 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Michel Dänzer
Sent: Wednesday, June 21, 2017 11:56 PM
To: [email protected]
Subject: [PATCH xf86-video-amdgpu] Increase reference count of FB assigned todrmmode_crtc->flip_pending
Quoted 6 lines
From: Michel Dänzer <[email protected]>
Otherwise, it could happen that we destroy the FB before the flip completes, resulting in use-after-free and most likely a crash.
Signed-off-by Michel Dänzer <[email protected]>
Quoted 69 lines
--- src/amdgpu_kms.c | 8 ++++---- src/drmmode_display.c | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-)src/amdgpu_kms.c +2
-2@@ -722,8 +722,8 @@ amdgpu_prime_scanout_flip(PixmapDirtyUpdatePtr ent)return ; } - drmmode_crtc->flip_pending = -amdgpu_pixmap_get_fb (drmmode_crtc- >scanout[scanout_id].pixmap); + drmmode_fb_reference(pAMDGPUEnt->fd, &drmmode_crtc- >flip_pending, + amdgpu_pixmap_get_fb(drmmode_crtc-Quoted 1 line
scanout[scanout_id].pixmap));
src/amdgpu_kms.c +2
-2if (!drmmode_crtc->flip_pending) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"Failed to get FB for PRIME flip.\n" );@@ -1011,8 +1011,8 @@ amdgpu_scanout_flip(ScreenPtr pScreen,AMDGPUInfoPtr info, return; } - drmmode_crtc->flip_pending = -amdgpu_pixmap_get_fb (drmmode_crtc- >scanout[scanout_id].pixmap); + drmmode_fb_reference(pAMDGPUEnt->fd, &drmmode_crtc- >flip_pending, + amdgpu_pixmap_get_fb(drmmode_crtc-Quoted 1 line
scanout[scanout_id].pixmap));
src/amdgpu_kms.c +0
-0if (!drmmode_crtc->flip_pending) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"Failed to get FB for scanout flip.\n" );src/drmmode_display.c +4
-1@@ -2196,8 +2196,11 @@ void drmmode_clear_pending_flip(xf86CrtcPtr crtc) {drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; +ScrnInfoPtr scrn = crtc->scrn; +AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (scrn); - drmmode_crtc->flip_pending =NULL ; +drmmode_fb_reference (pAMDGPUEnt->fd, &drmmode_crtc- >flip_pending, +NULL ); if (!crtc->enabled ||src/drmmode_display.c +2
-1(drmmode_crtc->pending_dpms_mode != DPMSModeOn &&@@ -2835,7 +2838,8 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn,ClientPtr client, goto flip_error; } - drmmode_crtc->flip_pending = fb; +drmmode_fb_reference (pAMDGPUEnt->fd, &drmmode_crtc->flip_pending, + fb); drm_queue_seq =0 ;}
Quoted 7 lines
--
2.11.0_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx