sna: Improve guard against loading palettes whilst headless

Whilst hosted, which is very similar to being headless, we do not even
have the kmode pointer and so checking kmode->count_crtcs is fatal.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2014-03-17 13:46:05 +00:00
parent 28ebbe8fa9
commit dc66e663a0
2 changed files with 10 additions and 1 deletions

View File

@ -3513,7 +3513,16 @@ bool sna_mode_pre_init(ScrnInfoPtr scrn, struct sna *sna)
num_fake = 1;
mode->kmode = drmModeGetResources(sna->kgem.fd);
if (mode->kmode &&
(mode->kmode->count_crtcs == 0 ||
mode->kmode->count_connectors == 0)) {
drmModeFreeResources(mode->kmode);
mode->kmode = NULL;
}
if (mode->kmode) {
assert(mode->kmode->count_crtcs);
assert(mode->kmode->count_connectors);
xf86CrtcConfigInit(scrn, &sna_mode_funcs);
XF86_CRTC_CONFIG_PTR(scrn)->xf86_crtc_notify = sna_crtc_config_notify;

View File

@ -1038,7 +1038,7 @@ sna_screen_init(SCREEN_INIT_ARGS_DECL)
if (!miCreateDefColormap(screen))
return FALSE;
if (sna->mode.kmode->count_crtcs &&
if (sna->mode.kmode &&
!xf86HandleColormaps(screen, 256, 8, sna_load_palette, NULL,
CMAP_RELOAD_ON_MODE_SWITCH |
CMAP_PALETTED_TRUECOLOR))