From 1771edcb44b564f83f509748b4e4cd5b7586e2a8 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 3 Jul 2008 18:57:09 +1000 Subject: [PATCH] modes: check the crtc is valid before using its desired modes. this fixes a crash I was getting on radeon rotate when gnome is running. I'm sure g-s-d was doing something bad, but really not crashing ftw. --- hw/xfree86/modes/xf86Crtc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 5a71bcfea..733106c4f 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -1714,9 +1714,11 @@ xf86SetScrnInfoModes (ScrnInfoPtr scrn) /* Set scrn->modes to the mode list for the 'compat' output */ scrn->modes = xf86DuplicateModes(scrn, output->probed_modes); - for (mode = scrn->modes; mode; mode = mode->next) - if (xf86ModesEqual (mode, &crtc->desiredMode)) - break; + if (crtc) { + for (mode = scrn->modes; mode; mode = mode->next) + if (xf86ModesEqual (mode, &crtc->desiredMode)) + break; + } if (scrn->modes != NULL) { /* For some reason, scrn->modes is circular, unlike the other mode