<div dir="ltr"><div>Reviewed-by: Gurchetan Singh <<a href="mailto:gurchetansingh@chromium.org">gurchetansingh@chromium.org</a>></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 11, 2017 at 11:57 AM, Emil Velikov <span dir="ltr"><<a href="mailto:emil.l.velikov@gmail.com" target="_blank">emil.l.velikov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Emil Velikov <<a href="mailto:emil.velikov@collabora.com">emil.velikov@collabora.com</a>><br>
<br>
Cc: Chad Versace <<a href="mailto:chadversary@chromium.org">chadversary@chromium.org</a>><br>
Cc: Gurchetan Singh <<a href="mailto:gurchetansingh@chromium.org">gurchetansingh@chromium.org</a>><br>
Signed-off-by: Emil Velikov <<a href="mailto:emil.velikov@collabora.com">emil.velikov@collabora.com</a>><br>
---<br>
 src/egl/drivers/dri2/platform_<wbr>surfaceless.c | 22 ++++++++--------------<br>
 1 file changed, 8 insertions(+), 14 deletions(-)<br>
<br>
diff --git a/src/egl/drivers/dri2/<wbr>platform_surfaceless.c b/src/egl/drivers/dri2/<wbr>platform_surfaceless.c<br>
index 7e887de09da..f001eda369c 100644<br>
--- a/src/egl/drivers/dri2/<wbr>platform_surfaceless.c<br>
+++ b/src/egl/drivers/dri2/<wbr>platform_surfaceless.c<br>
@@ -279,6 +279,7 @@ dri2_initialize_surfaceless(_<wbr>EGLDriver *drv, _EGLDisplay *disp)<br>
    if (!dri2_dpy)<br>
       return _eglError(EGL_BAD_ALLOC, "eglInitialize");<br>
<br>
+   dri2_dpy->fd = -1;<br>
    disp->DriverData = (void *) dri2_dpy;<br>
<br>
    const int limit = 64;<br>
@@ -301,25 +302,27 @@ dri2_initialize_surfaceless(_<wbr>EGLDriver *drv, _EGLDisplay *disp)<br>
             break;<br>
          }<br>
          free(dri2_dpy->driver_name);<br>
+         dri2_dpy->driver_name = NULL;<br>
       }<br>
       close(dri2_dpy->fd);<br>
+      dri2_dpy->fd = -1;<br>
    }<br>
<br>
    if (!driver_loaded) {<br>
       err = "DRI2: failed to load driver";<br>
-      goto cleanup_display;<br>
+      goto cleanup;<br>
    }<br>
<br>
    dri2_dpy->loader_extensions = image_loader_extensions;<br>
<br>
    if (!dri2_create_screen(disp)) {<br>
       err = "DRI2: failed to create screen";<br>
-      goto cleanup_driver;<br>
+      goto cleanup;<br>
    }<br>
<br>
    if (!surfaceless_add_configs_for_<wbr>visuals(drv, disp)) {<br>
       err = "DRI2: failed to add configs";<br>
-      goto cleanup_screen;<br>
+      goto cleanup;<br>
    }<br>
<br>
    /* Fill vtbl last to prevent accidentally calling virtual function during<br>
@@ -329,16 +332,7 @@ dri2_initialize_surfaceless(_<wbr>EGLDriver *drv, _EGLDisplay *disp)<br>
<br>
    return EGL_TRUE;<br>
<br>
-cleanup_screen:<br>
-   dri2_dpy->core->destroyScreen(<wbr>dri2_dpy->dri_screen);<br>
-<br>
-cleanup_driver:<br>
-   dlclose(dri2_dpy->driver);<br>
-   free(dri2_dpy->driver_name);<br>
-   close(dri2_dpy->fd);<br>
-cleanup_display:<br>
-   free(dri2_dpy);<br>
-   disp->DriverData = NULL;<br>
-<br>
+cleanup:<br>
+   dri2_display_destroy(disp);<br>
    return _eglError(EGL_NOT_INITIALIZED, err);<br>
 }<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.12.2<br>
<br>
</font></span></blockquote></div><br></div>