surfaceless: Fix swrast-path segfault when loader doesn't know driver name.
authorEric Anholt <eric@anholt.net>
Mon, 29 Jul 2019 23:25:56 +0000 (16:25 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 13 Aug 2019 17:30:01 +0000 (10:30 -0700)
If we're hitting the swrast fallback path here, it's probably because
we stumbled across a KMS-only device (such as the ASpeed that some of
our CI runners have) that will then return a NULL driver_name.  Don't
crash in that case.

Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
src/egl/drivers/dri2/platform_surfaceless.c

index 210f8188b96baec9aeaeb11f3ad05cc70e777e44..8eeb2d4ed43ba660d6753fd9225d45eb61982f26 100644 (file)
@@ -294,8 +294,9 @@ surfaceless_probe_device(_EGLDisplay *disp, bool swrast)
           * are unavailable since 6c5ab, and kms_swrast is more
           * feature complete than swrast.
           */
-         if (strcmp(driver_name, "vgem") == 0 ||
-             strcmp(driver_name, "virtio_gpu") == 0)
+         if (driver_name &&
+             (strcmp(driver_name, "vgem") == 0 ||
+              strcmp(driver_name, "virtio_gpu") == 0))
             dri2_dpy->driver_name = strdup("kms_swrast");
          free(driver_name);
       } else {