Revert "egl/dri2: Don't dlclose() the driver on dri2_load_driver_common failure"

This reverts commit 1b87f4058d.

dlclose() of the handle is perfectly reasonable, a follow-up NULL
assignment is missing.

As-is this causes a leak for nearly every platform, since they call
dri2_load_driver* initially, followed by a second swrast fallback call.

Some platforms even loop through the existing drivers probing.

Revert the commit and add the NULL check.

Fixes: 1b87f4058d ("egl/dri2: Don't dlclose() the driver on dri2_load_driver_common failure")
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4084>
(cherry picked from commit d3c9143971)
This commit is contained in:
Emil Velikov 2020-03-05 13:05:36 +00:00 committed by Dylan Baker
parent e594e7fa27
commit a93c67d633
2 changed files with 5 additions and 3 deletions

View file

@ -2776,7 +2776,7 @@
"description": "Revert \"egl/dri2: Don't dlclose() the driver on dri2_load_driver_common failure\"",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"master_sha": null,
"because_sha": "1b87f4058de84d7a0bb4ead0c4f4b024d4cce8fb"
},

View file

@ -784,9 +784,11 @@ dri2_load_driver_common(_EGLDisplay *disp,
if (!extensions)
return EGL_FALSE;
if (!dri2_bind_extensions(dri2_dpy, driver_extensions, extensions, false))
if (!dri2_bind_extensions(dri2_dpy, driver_extensions, extensions, false)) {
dlclose(dri2_dpy->driver);
dri2_dpy->driver = NULL;
return EGL_FALSE;
}
dri2_dpy->driver_extensions = extensions;
dri2_bind_extensions(dri2_dpy, optional_driver_extensions, extensions, true);