radeon: drmGetVersion can return NULL

Do not crash on scenarios where drmGetVersion returns NULL.
Make Radeon driver initialization more robust.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/476

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: David Heidelberg <david.heidelberg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20402>
This commit is contained in:
David Heidelberg
2022-12-21 01:57:31 +01:00
committed by Marge Bot
parent 739a08ad23
commit fa07dcb588
2 changed files with 8 additions and 1 deletions
+5 -1
View File
@@ -1486,8 +1486,12 @@ static struct pipe_screen *radeonsi_screen_create_impl(struct radeon_winsys *ws,
struct pipe_screen *radeonsi_screen_create(int fd, const struct pipe_screen_config *config)
{
drmVersionPtr version = drmGetVersion(fd);
struct radeon_winsys *rw = NULL;
drmVersionPtr version;
version = drmGetVersion(fd);
if (!version)
return NULL;
driParseConfigFiles(config->options, config->options_info, 0, "radeonsi",
NULL, NULL, NULL, 0, NULL, 0);
@@ -152,6 +152,9 @@ static bool do_winsys_init(struct radeon_drm_winsys *ws)
/* Get DRM version. */
version = drmGetVersion(ws->fd);
if (!version)
return false;
if (version->version_major != 2 ||
version->version_minor < 50) {
fprintf(stderr, "%s: DRM version is %d.%d.%d but this driver is "