loader: Handle failure to load DRI driver library

I factored out the chunk of loader code that dlopen()s
libraries from the rest of the DRI driver loader function
in this commit:

  commit bc343154f8
  Author: James Jones <jajones@nvidia.com>
  Date:   Thu Apr 22 23:17:08 2021 -0700

  loader: Factor out driver library loading code

However, I failed to adjust the DRI loader function that
now uses the new helper function to handle the case where
the requested DRI library is not found.

This change restores the prior behavior, and also ensures
loader_open_driver() consistently returns NULL in the
out_driver_handle parameter on failure.

Fixes: bc343154f8 ("loader: Factor out driver library loading code")
Signed-off-by: James Jones <jajones@nvidia.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11807>
This commit is contained in:
James Jones 2021-07-09 08:40:19 -07:00 committed by Marge Bot
parent b97cd93b35
commit b2252de03e
1 changed files with 5 additions and 0 deletions

View File

@ -612,6 +612,9 @@ loader_open_driver(const char *driver_name,
void *driver = loader_open_driver_lib(driver_name, "_dri", search_path_vars,
DEFAULT_DRIVER_DIR, true);
if (!driver)
goto failed;
get_extensions_name = loader_get_extensions_name(driver_name);
if (get_extensions_name) {
get_extensions = dlsym(driver, get_extensions_name);
@ -630,8 +633,10 @@ loader_open_driver(const char *driver_name,
log_(_LOADER_WARNING,
"MESA-LOADER: driver exports no extensions (%s)\n", dlerror());
dlclose(driver);
driver = NULL;
}
failed:
*out_driver_handle = driver;
return extensions;
}