xf86-video-intel: src/intel_dri.c

Keith Packard keithp at kemper.freedesktop.org
Thu Mar 24 17:12:54 PDT 2011


 src/intel_dri.c |   18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

New commits:
commit 7ccbec801e9ee32fc110db730dfec674a94dea21
Author: Keith Packard <keithp at keithp.com>
Date:   Thu Mar 24 11:06:57 2011 -0700

    Recover from i830_dri2_add_frame_event out-of-memory condition
    
    If adding either the frame or client resources fails, we need to clean
    up afterwards properly.
    
    First, add_frame_event needs to internally clean up after itself by
    undoing any partial execution. Second, the callers need to look at the
    return value and free the swap/flip info structure when necessary.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Julien Cristau <jcristau at debian.org>

diff --git a/src/intel_dri.c b/src/intel_dri.c
index 3b80823..16e42f1 100644
--- a/src/intel_dri.c
+++ b/src/intel_dri.c
@@ -625,8 +625,10 @@ i830_dri2_add_frame_event(DRI2FrameEventPtr frame_event)
 	if (!AddResource(frame_event->client_id, frame_event_client_type, frame_event))
 		return FALSE;
 
-	if (!AddResource(frame_event->drawable_id, frame_event_drawable_type, frame_event))
+	if (!AddResource(frame_event->drawable_id, frame_event_drawable_type, frame_event)) {
+		FreeResourceByType(frame_event->client_id, frame_event_client_type, TRUE);
 		return FALSE;
+	}
 
 	return TRUE;
 }
@@ -705,7 +707,10 @@ I830DRI2ScheduleFlip(struct intel_screen_private *intel,
 	flip_info->event_data = data;
 	flip_info->frame = target_msc;
 
-	i830_dri2_add_frame_event(flip_info);
+	if (!i830_dri2_add_frame_event(flip_info)) {
+	    free(flip_info);
+	    return FALSE;
+	}
 
 	/* Page flip the full screen buffer */
 	back_priv = back->driverPrivate;
@@ -955,11 +960,16 @@ I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front,
 	swap_info->event_data = data;
 	swap_info->front = front;
 	swap_info->back = back;
+
+	if (!i830_dri2_add_frame_event(swap_info)) {
+	    free(swap_info);
+	    swap_info = NULL;
+	    goto blit_fallback;
+	}
+
 	I830DRI2ReferenceBuffer(front);
 	I830DRI2ReferenceBuffer(back);
 
-	i830_dri2_add_frame_event(swap_info);
-
 	/* Get current count */
 	vbl.request.type = DRM_VBLANK_RELATIVE;
 	if (pipe > 0)


More information about the xorg-commit mailing list