fix fd leak 57/239057/1
authorChangyeon Lee <cyeon.lee@samsung.com>
Tue, 21 Jul 2020 11:06:40 +0000 (20:06 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Tue, 21 Jul 2020 11:06:40 +0000 (20:06 +0900)
Change-Id: I90e1cf86227728a93c714d1e593de4acf52deea4

src/tbm_bufmgr_sprd.c

index 7161fa5..46e278e 100644 (file)
@@ -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)