diff options
Diffstat (limited to 'src/tbm_backend_dumb.c')
-rw-r--r-- | src/tbm_backend_dumb.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/tbm_backend_dumb.c b/src/tbm_backend_dumb.c index d8c91cb..931d71e 100644 --- a/src/tbm_backend_dumb.c +++ b/src/tbm_backend_dumb.c @@ -755,28 +755,28 @@ tbm_dumb_bufmgr_import_fd(hal_tbm_bufmgr *bufmgr, hal_tbm_fd key, hal_tbm_error * kernels will just fail, in which case we fall back to the * provided (estimated or guess size). */ real_size = lseek(key, 0, SEEK_END); + if (real_size == -1) { + /* Open the same GEM object only for finding out its size */ + open_arg.name = name; + if (drmIoctl(bufmgr_data->fd, DRM_IOCTL_GEM_OPEN, &open_arg)) { + TBM_BACKEND_ERR("fail to DRM_IOCTL_GEM_OPEN gem:%d name:%d (%m)", + gem, name); + if (error) + *error = HAL_TBM_ERROR_INVALID_OPERATION; + return NULL; + } - /* Open the same GEM object only for finding out its size */ - open_arg.name = name; - if (drmIoctl(bufmgr_data->fd, DRM_IOCTL_GEM_OPEN, &open_arg)) { - TBM_BACKEND_ERR("fail to DRM_IOCTL_GEM_OPEN gem:%d name:%d (%m)", - gem, name); - if (error) - *error = HAL_TBM_ERROR_INVALID_OPERATION; - return NULL; - } - - /* Free gem handle to avoid a memory leak*/ - close_arg.handle = open_arg.handle; - if (drmIoctl(bufmgr_data->fd, DRM_IOCTL_GEM_CLOSE, &close_arg)) { - TBM_BACKEND_ERR("fail to DRM_IOCTL_GEM_CLOSE gem:%d (%m)", open_arg.handle); - if (error) - *error = HAL_TBM_ERROR_INVALID_OPERATION; - return NULL; - } + /* Free gem handle to avoid a memory leak*/ + close_arg.handle = open_arg.handle; + if (drmIoctl(bufmgr_data->fd, DRM_IOCTL_GEM_CLOSE, &close_arg)) { + TBM_BACKEND_ERR("fail to DRM_IOCTL_GEM_CLOSE gem:%d (%m)", open_arg.handle); + if (error) + *error = HAL_TBM_ERROR_INVALID_OPERATION; + return NULL; + } - if (real_size == -1) real_size = open_arg.size; + } bo_data = calloc(1, sizeof(struct _tbm_dumb_bo)); if (!bo_data) { |