}
/* LCOV_EXCL_STOP */
bo->bo_data = bo_data;
+ bo->allocated_hal_tbm_bo = 1;
} else if (bufmgr->backend_module_data) {
bo_data = bufmgr->bufmgr_func->bufmgr_alloc_bo(bufmgr->bufmgr_data, (unsigned int)size, flags, &error);
if (!bo_data) {
/* call the bo_free */
if (bo->bufmgr->use_hal_tbm) {
- hal_tbm_bo_free(bo->bo_data);
- bo->bo_data = NULL;
+ // call hal_tbm_bo_free when bo is created by tbm_bo_alloc api.
+ if (bo->allocated_hal_tbm_bo) {
+ hal_tbm_bo_free(bo->bo_data);
+ bo->bo_data = NULL;
+ bo->allocated_hal_tbm_bo = 0;
+ }
} else if (bo->bufmgr->backend_module_data) {
bo->bufmgr->bo_func->bo_free(bo->bo_data);
bo->bo_data = NULL;
unsigned int map_cnt; /* device map count */
tbm_backend_bo_data *bo_data; /* bo data of the backend module */
+ int allocated_hal_tbm_bo; /* this bo is by calling hal_tbm_bo_alloc */
};
/**