xf86Crtc: handle no outputs with no modes harder.

If you started an X server with no connected outputs, we pick a default
1024x768 mode, however if you then ran an xvidmode using app against that
server it would segfault the server due to not finding any valid modes.

This was due to the no output mode set code, only adding the modes to the
scrn->modes once, when something called randr 1.2 xf86SetScrnInfoModes would
get called and remove all the modes and we'd end up with 0.

This change fixes xf86SetScrnInfoModes to always report a scrn mode of at
least 1024x768, and pushes the initial configuration to just call it instead
of setting up the mode itself.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=746926

I've seen other bugs like this on other distros so it might also actually fix them.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Dave Airlie 2011-10-20 14:43:01 +01:00 committed by Keith Packard
parent ff61592441
commit 17416e88dc

View File

@ -1915,19 +1915,25 @@ xf86SetScrnInfoModes (ScrnInfoPtr scrn)
break;
}
if (scrn->modes != NULL) {
/* For some reason, scrn->modes is circular, unlike the other mode
* lists. How great is that?
*/
for (last = scrn->modes; last && last->next; last = last->next)
;
last->next = scrn->modes;
scrn->modes->prev = last;
if (mode) {
while (scrn->modes != mode)
scrn->modes = scrn->modes->next;
}
if (!scrn->modes) {
scrn->modes = xf86ModesAdd(scrn->modes,
xf86CVTMode(scrn->display->virtualX,
scrn->display->virtualY,
60, 0, 0));
}
/* For some reason, scrn->modes is circular, unlike the other mode
* lists. How great is that?
*/
for (last = scrn->modes; last && last->next; last = last->next)
;
last->next = scrn->modes;
scrn->modes->prev = last;
if (mode) {
while (scrn->modes != mode)
scrn->modes = scrn->modes->next;
}
scrn->currentMode = scrn->modes;
#ifdef XFreeXDGA
if (scrn->pScreen)
@ -2529,16 +2535,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
width, height);
}
if (have_outputs) {
/* Mirror output modes to scrn mode list */
xf86SetScrnInfoModes (scrn);
} else {
/* Clear any existing modes from scrn->modes */
while (scrn->modes != NULL)
xf86DeleteMode(&scrn->modes, scrn->modes);
scrn->modes = xf86ModesAdd(scrn->modes,
xf86CVTMode(width, height, 60, 0, 0));
}
xf86SetScrnInfoModes (scrn);
success = TRUE;
bailout: