targets/gbm: exit gracefully if pipe_loader_drm_probe_fd is not available
authorEmil Velikov <emil.l.velikov@gmail.com>
Sat, 22 Feb 2014 16:20:04 +0000 (16:20 +0000)
committerEmil Velikov <emil.l.velikov@gmail.com>
Mon, 24 Feb 2014 14:51:45 +0000 (14:51 +0000)
When one builds without gallium_drm_loader, the above function will
not be available, thus we'll segfault in gallium_screen_create due
to memory access violation.

Tested-by: Tom Stellard <thomas.stellard@amd.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=75335
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
src/gallium/targets/gbm/gbm.c

index deaa401ad115641f86d9d258a54223d567b3ea5c..160cbb84380fde66b9cc2610688f838534efb28d 100644 (file)
@@ -49,13 +49,14 @@ int
 gallium_screen_create(struct gbm_gallium_drm_device *gdrm)
 {
    struct pipe_loader_device *dev;
-#ifdef HAVE_PIPE_LOADER_DRM
-   int ret;
+   int ret = 0;
 
+#ifdef HAVE_PIPE_LOADER_DRM
    ret = pipe_loader_drm_probe_fd(&dev, gdrm->base.base.fd, true);
+#endif /* HAVE_PIPE_LOADER_DRM */
+
    if (!ret)
       return -1;
-#endif /* HAVE_PIPE_LOADER_DRM */
 
    gdrm->screen = pipe_loader_create_screen(dev, get_library_search_path());
    if (gdrm->screen == NULL) {