[PATCH] Work around sporadic segfault on resume with intel/KMS due to cursor->bits == NULL.

Matthias Hopf mhopf at suse.de
Fri Sep 4 08:32:45 PDT 2009


Apparently SavedCursor is sometime tried to be set while already being set.
---
 hw/xfree86/modes/xf86Cursors.c |    8 ++++++++
 hw/xfree86/ramdac/xf86Cursor.c |   17 ++++++++++-------
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c
index 8c5a94c..3436636 100644
--- a/hw/xfree86/modes/xf86Cursors.c
+++ b/hw/xfree86/modes/xf86Cursors.c
@@ -461,6 +461,10 @@ xf86_use_hw_cursor (ScreenPtr screen, CursorPtr cursor)
     xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
     xf86CursorInfoPtr	cursor_info = xf86_config->cursor_info;
 
+    if (xf86_config->cursor == cursor) {
+	xf86DrvMsg(index, X_ERROR, "Trying to set already set cursor.\n");
+	return FALSE;
+    }
     if (xf86_config->cursor)
 	FreeCursor (xf86_config->cursor, None);
     xf86_config->cursor = cursor;
@@ -480,6 +484,10 @@ xf86_use_hw_cursor_argb (ScreenPtr screen, CursorPtr cursor)
     xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
     xf86CursorInfoPtr	cursor_info = xf86_config->cursor_info;
     
+    if (xf86_config->cursor == cursor) {
+	xf86DrvMsg(index, X_ERROR, "Trying to set already set cursor.\n");
+	return FALSE;
+    }
     if (xf86_config->cursor)
 	FreeCursor (xf86_config->cursor, None);
     xf86_config->cursor = cursor;
diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c
index 6b71f46..7aa7039 100644
--- a/hw/xfree86/ramdac/xf86Cursor.c
+++ b/hw/xfree86/ramdac/xf86Cursor.c
@@ -209,13 +209,16 @@ xf86CursorEnableDisableFBAccess(
     xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
 	&pScreen->devPrivates, xf86CursorScreenKey);
 
-    if (!enable && ScreenPriv->CurrentCursor != NullCursor) {
-        CursorPtr currentCursor = ScreenPriv->CurrentCursor;
-        xf86CursorSetCursor(pDev, pScreen, NullCursor, ScreenPriv->x,
-                ScreenPriv->y); 
-        ScreenPriv->isUp = FALSE;
-	ScreenPriv->SWCursor = TRUE;
-	ScreenPriv->SavedCursor = currentCursor;
+    if (!enable) {
+	if (ScreenPriv->CurrentCursor != NullCursor) {
+	    CursorPtr currentCursor = ScreenPriv->CurrentCursor;
+	    xf86CursorSetCursor(pDev, pScreen, NullCursor, ScreenPriv->x,
+				ScreenPriv->y); 
+	    ScreenPriv->isUp = FALSE;
+	    ScreenPriv->SWCursor = TRUE;
+	    ScreenPriv->SavedCursor = currentCursor;
+	} else
+	    ScreenPriv->SavedCursor = NULL;
     }
 
     if (ScreenPriv->EnableDisableFBAccess)
-- 
1.6.0.2


--zYM0uCDKw75PZbzx--


More information about the xorg-devel mailing list