lp: Only close udmabuf handle if its valid

Also change ifdef's from just `HAVE_LIBDRM` to check for both LIBDRM
and for UDMABUF HEADER. preventing unbalanced guards preventing part of
the code from being included if you just have LIBDRM or just have the
udmabuf headers.

Fixes: 4cfaf10c ("llvmpipe: Only use udmabuf with libdrm")
Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31877>
This commit is contained in:
Lucas Fryzek 2024-10-28 13:02:26 -04:00 committed by Marge Bot
parent 3a962a28e7
commit 159fb9691d
2 changed files with 4 additions and 3 deletions

View file

@ -939,8 +939,9 @@ llvmpipe_destroy_screen(struct pipe_screen *_screen)
glsl_type_singleton_decref();
#ifdef HAVE_LIBDRM
close(screen->udmabuf_fd);
#if defined(HAVE_LIBDRM) && defined(HAVE_LINUX_UDMABUF_H)
if (screen->udmabuf_fd != -1)
close(screen->udmabuf_fd);
#endif
#if DETECT_OS_LINUX

View file

@ -75,7 +75,7 @@ struct llvmpipe_screen
struct disk_cache *disk_shader_cache;
#ifdef HAVE_LIBDRM
#if defined(HAVE_LIBDRM) && defined(HAVE_LINUX_UDMABUF_H)
int udmabuf_fd;
#endif