From 2229328cf9213bfbfac2e0e5cc411a41bcaae695 Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Wed, 26 Aug 2020 15:32:08 +0200 Subject: [PATCH] renderonly: close the gpu fd when destroying renderonly MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Currently the screen destruction closes the dup'ed fd, but not the original renderonly gpu fd, which is kept around for the lifetime of the renderonly. Squashed revert of "vc4: Don't leak the GPU fd for renderonly usage." (commit 99ef66c325a99b3e191987d8327e7e4cd4aafcd7) as requested by Eric. Signed-off-by: Lucas Stach Reviewed-by: Guido Günther Reviewed-by: Eric Anholt Reviewed-by: Christian Gmeiner Reviewed-by: Alyssa Rosenzweig Part-of: --- src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c | 3 +++ src/gallium/winsys/vc4/drm/vc4_drm_winsys.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c b/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c index 9000a6a..790ed7d 100644 --- a/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c +++ b/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c @@ -40,6 +40,9 @@ static void kmsro_ro_destroy(struct renderonly *ro) { + if (ro->gpu_fd >= 0) + close(ro->gpu_fd); + FREE(ro); } diff --git a/src/gallium/winsys/vc4/drm/vc4_drm_winsys.c b/src/gallium/winsys/vc4/drm/vc4_drm_winsys.c index a507821..ae40992 100644 --- a/src/gallium/winsys/vc4/drm/vc4_drm_winsys.c +++ b/src/gallium/winsys/vc4/drm/vc4_drm_winsys.c @@ -61,5 +61,5 @@ struct pipe_screen * vc4_drm_screen_create_renderonly(struct renderonly *ro, const struct pipe_screen_config *config) { - return vc4_screen_create(ro->gpu_fd, ro); + return vc4_screen_create(fcntl(ro->gpu_fd, F_DUPFD_CLOEXEC, 3), ro); } -- 2.7.4