diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-03-12 18:39:07 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-03-12 18:43:32 +0000 |
commit | 50374fb4947e6682b6c8aced639b422110b6ec98 (patch) | |
tree | 35f5fb85a0500513d6e43511e9f2dd976a25c7d3 | |
parent | c79a189b6f06a58ddbd92427b6c57a0bdfb1e16c (diff) |
uxa/glamor: Prevent a crash when trying to load a misconfigured glamor
Glamor requires that glamoregl is explicitly loaded via Section "Module"
or else it currently crashes.
Based on a patch by Michel Dänzer for xf86-video-ati.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/intel_glamor.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/intel_glamor.c b/src/intel_glamor.c index 55eb2de3..0c4e3a77 100644 --- a/src/intel_glamor.c +++ b/src/intel_glamor.c @@ -72,6 +72,18 @@ intel_glamor_create_screen_resources(ScreenPtr screen) return TRUE; } +static Bool +intel_glamor_enabled(intel_screen_private *intel) +{ + const char *s; + + s = xf86GetOptValString(intel->Options, OPTION_ACCEL_METHOD); + if (s == NULL) + return FALSE; + + return strcasecmp(s, "glamor") == 0; +} + Bool intel_glamor_pre_init(ScrnInfoPtr scrn) { @@ -79,6 +91,16 @@ intel_glamor_pre_init(ScrnInfoPtr scrn) pointer glamor_module; CARD32 version; + if (!intel_glamor_enabled(intel)) + return TRUE; + + if (!xf86LoaderCheckSymbol("glamor_egl_init")) { + xf86DrvMsg(scrn->scrnIndex, X_ERROR, + "glamor requires Load \"glamoregl\" in " + "Section \"Module\", disabling.\n"); + return TRUE; + } + /* Load glamor module */ if ((glamor_module = xf86LoadSubModule(scrn, GLAMOR_EGL_MODULE_NAME))) { version = xf86GetModuleVersion(glamor_module); @@ -173,18 +195,6 @@ intel_glamor_finish_access(PixmapPtr pixmap, uxa_access_t access) return; } -static Bool -intel_glamor_enabled(intel_screen_private *intel) -{ - const char *s; - - s = xf86GetOptValString(intel->Options, OPTION_ACCEL_METHOD); - if (s == NULL) - return FALSE; - - return strcasecmp(s, "glamor") == 0; -} - Bool intel_glamor_init(ScreenPtr screen) { @@ -194,9 +204,6 @@ intel_glamor_init(ScreenPtr screen) if ((intel->uxa_flags & UXA_GLAMOR_EGL_INITIALIZED) == 0) goto fail; - if (!intel_glamor_enabled(intel)) - goto fail; - if (!glamor_init(screen, GLAMOR_INVERTED_Y_AXIS | GLAMOR_USE_EGL_SCREEN)) { xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to initialize glamor.\n"); |