From e2e1af4397657413892f56f9b4817da68c82a714 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Tue, 21 Jul 2020 20:06:40 +0900 Subject: [PATCH] fix fd leak Change-Id: I90e1cf86227728a93c714d1e593de4acf52deea4 --- src/tbm_bufmgr_sprd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tbm_bufmgr_sprd.c b/src/tbm_bufmgr_sprd.c index 7161fa5..46e278e 100644 --- a/src/tbm_bufmgr_sprd.c +++ b/src/tbm_bufmgr_sprd.c @@ -1778,6 +1778,7 @@ tbm_sprd_init(tbm_bufmgr bufmgr, tbm_error_e *error) tbm_backend_bo_func *bo_func = NULL; int fp; tbm_error_e err; + int set_master = 0; if (!bufmgr) { TBM_ERR("bufmgr is null.\n"); @@ -1807,6 +1808,7 @@ tbm_sprd_init(tbm_bufmgr bufmgr, tbm_error_e *error) if (drmIsMaster(bufmgr_sprd->fd)) { tbm_drm_helper_set_tbm_master_fd(bufmgr_sprd->fd); + set_master = 1; bufmgr_sprd->device_name = drmGetDeviceNameFromFd(bufmgr_sprd->fd); if (!bufmgr_sprd->device_name) { @@ -1943,7 +1945,7 @@ fail_alloc_bufmgr_func: if (bufmgr_sprd->hashBos) drmHashDestroy(bufmgr_sprd->hashBos); fail_init_cache_state: - if (tbm_drm_helper_get_master_fd() >= 0) + if (set_master) tbm_drm_helper_unset_tbm_master_fd(); tbm_drm_helper_unset_fd(); if (bufmgr_sprd->device_name) -- 2.7.4