diff options
author | SooChan Lim <sc1.lim@samsung.com> | 2021-06-14 12:07:51 +0900 |
---|---|---|
committer | SooChan Lim <sc1.lim@samsung.com> | 2021-06-14 12:07:51 +0900 |
commit | 4ea82b90dcef45e70a0e61f61389bdb049d50f82 (patch) | |
tree | 5201590d60452de213b093305966fce5277aaf58 | |
parent | 4796746ae847180f0992c0913302be7e9e36d287 (diff) | |
download | libtbm-shm-4ea82b90dcef45e70a0e61f61389bdb049d50f82.tar.gz libtbm-shm-4ea82b90dcef45e70a0e61f61389bdb049d50f82.tar.bz2 libtbm-shm-4ea82b90dcef45e70a0e61f61389bdb049d50f82.zip |
dup key at tbm_shm_bufmgr_import_fd
TBM backend duplicated the fd when import_fd is requested.
Change-Id: Id8db29dff685406502064c020c7897ca2e1893b5
-rw-r--r-- | src/libhal-backend-tbm-shm/tbm_backend_shm.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/libhal-backend-tbm-shm/tbm_backend_shm.c b/src/libhal-backend-tbm-shm/tbm_backend_shm.c index f26f80b..98b51d5 100644 --- a/src/libhal-backend-tbm-shm/tbm_backend_shm.c +++ b/src/libhal-backend-tbm-shm/tbm_backend_shm.c @@ -605,6 +605,7 @@ tbm_shm_bufmgr_import_fd(hal_tbm_bufmgr *bufmgr, hal_tbm_fd key, hal_tbm_error * tbm_shm_bo *bo_data; int real_size; char buf[STRERR_BUFSIZE]; + hal_tbm_fd fd; if (key < 0) { TBM_BACKEND_ERR("Invalid fd(%d)\n", key); @@ -642,12 +643,22 @@ tbm_shm_bufmgr_import_fd(hal_tbm_bufmgr *bufmgr, hal_tbm_fd key, hal_tbm_error * return 0; } + fd = dup(key); + if (fd < 0) { + TBM_BACKEND_ERR("dup failed: %m"); + free(bo_data); + if (error) + *error = HAL_TBM_ERROR_INVALID_PARAMETER; + return 0; + } + bo_data->size = real_size; - bo_data->fd = key; + bo_data->fd = fd; bo_data->flags_tbm = HAL_TBM_BO_DEFAULT | HAL_TBM_BO_NONCACHABLE; - TBM_BACKEND_DBG(" [%s] bo:%p, shm:%d, flags:%d, size:%d\n", target_name(), bo_data, bo_data->fd, - bo_data->flags_tbm, bo_data->size); + TBM_BACKEND_DBG(" [%s] bo:%p, shm:%d, flags:%d, size:%d imported_fd:%d\n", target_name(), bo_data, bo_data->fd, + bo_data->flags_tbm, bo_data->size, key); + if (error) *error = HAL_TBM_ERROR_NONE; |