xf86drm: ignore symlinks in process_device()

If the user has some UDev rules in place that creates symlinks for
one of the card or render nodes, and the name of the symlink is
too long, then drmDeviceAlloc() ends up truncating the name of
the node.
This in turn results in chaos in different subsystems. E.g.
vulkaninfo dies early with this:

Code 0 : failed to stat DRM primary node /dev/dri/my-favorite- (VK_ERROR_INITIALIZATION_FAILED)
(if the symlink is called /dev/dri/my-favorite-card-node)

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
main
Tobias Jakobi 2023-12-25 00:21:44 +01:00 committed by Simon Ser
parent 140943281b
commit 7ab1cdac90
1 changed files with 4 additions and 1 deletions

View File

@ -4479,7 +4479,10 @@ process_device(drmDevicePtr *device, const char *d_name,
return -1; return -1;
snprintf(node, PATH_MAX, "%s/%s", DRM_DIR_NAME, d_name); snprintf(node, PATH_MAX, "%s/%s", DRM_DIR_NAME, d_name);
if (stat(node, &sbuf)) if (lstat(node, &sbuf))
return -1;
if (S_ISLNK(sbuf.st_mode))
return -1; return -1;
maj = major(sbuf.st_rdev); maj = major(sbuf.st_rdev);