[patch] xserver: fix deadloop when preferred mode > 1

Hong Liu hong.liu at intel.com
Fri Sep 28 00:57:08 PDT 2007


When preferred mode option is enabled and there are more than 1 mode
matches the preferred mode, X will get in dead-loop.

Thanks,
Hong

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 064ff16..78479bb 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -1400,25 +1400,33 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY)
 
 	if (preferred_mode)
 	{
-	    for (mode = output->probed_modes; mode; mode = mode->next)
+	    mode = output->probed_modes;
+	    while (mode)
 	    {
+		DisplayModePtr next;
+
 		if (!strcmp (preferred_mode, mode->name))
 		{
+		    next = mode->next;
 		    if (mode != output->probed_modes)
 		    {
 			if (mode->prev)
-			    mode->prev->next = mode->next;
-			if (mode->next)
-			    mode->next->prev = mode->prev;
+			    mode->prev->next = next;
+			if (next)
+			    next->prev = mode->prev;
 			mode->next = output->probed_modes;
 			output->probed_modes->prev = mode;
 			mode->prev = NULL;
 			output->probed_modes = mode;
 		    }
 		    mode->type |= M_T_PREFERRED;
+		    mode = next;
+		    continue;
 		}
 		else
 		    mode->type &= ~M_T_PREFERRED;
+
+		mode = mode->next;
 	    }
 	}
 	



More information about the xorg mailing list