diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2014-03-17 13:46:05 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2014-03-17 13:50:18 +0000 |
commit | dc66e663a06f2ce7685eba1fdf9fad01786bcb4f (patch) | |
tree | 76cc61c2265b7a1cc600f59c12f2d0cffbe28b49 | |
parent | 28ebbe8fa902a1d3ee4ecbda5041de5e7b68ada7 (diff) |
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>
-rw-r--r-- | src/sna/sna_display.c | 9 | ||||
-rw-r--r-- | src/sna/sna_driver.c | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index de08cb9e..6e2d118f 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -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; diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c index ef301497..5e1f4400 100644 --- a/src/sna/sna_driver.c +++ b/src/sna/sna_driver.c @@ -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)) |