tbm_bo: free hal_tbm_bo when it is allocated by tbm_bo_alloc 42/257742/6 submit/tizen/20210608.001159
authorSooChan Lim <sc1.lim@samsung.com>
Fri, 30 Apr 2021 07:03:46 +0000 (16:03 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Mon, 10 May 2021 05:41:04 +0000 (14:41 +0900)
The hal_tbm_do which is allocated by tbm_bo_alloc_with_tbm_backend_data
is not freed at this _tbm_bo_free. The hal_tbm_bo from hal_tbm_surface
will be and should be freed at the hal-tbm-api backend module.

Change-Id: Ie10ecc370d1365a2c4a1067d3295d3fb632d7a0d

src/tbm_bo.c
src/tbm_bufmgr_int.h

index 044b5ec..0f2b138 100644 (file)
@@ -384,6 +384,7 @@ tbm_bo_alloc(tbm_bufmgr bufmgr, int size, int flags)
                }
                /* 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) {
@@ -1625,8 +1626,12 @@ _tbm_bo_free(tbm_bo bo)
 
        /* 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;
index b6c97c7..0eb5f79 100644 (file)
@@ -186,6 +186,7 @@ struct _tbm_bo {
        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 */
 };
 
 /**