Tdm_bo: Add null checking before use 23/255023/1
authorJunkyeong Kim <jk0430.kim@samsung.com>
Thu, 11 Mar 2021 08:42:42 +0000 (17:42 +0900)
committerJunkyeong Kim <jk0430.kim@samsung.com>
Thu, 11 Mar 2021 08:42:46 +0000 (17:42 +0900)
Change-Id: I1b780b2eaeaac3cbf316156475a217f0628bef26
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
src/tbm_bo.c

index eb188f1..b5d5b53 100644 (file)
@@ -464,8 +464,9 @@ tbm_bo_alloc_with_format(tbm_bufmgr bufmgr, int format, int bo_idx, int width,
                if (ret != HAL_TBM_ERROR_NONE) {
                        if (ret != HAL_TBM_ERROR_NOT_SUPPORTED) {
                                TBM_ERR("error: fail to tbm_bo_alloc_with_format\n");
+                               if (error)
+                                       _tbm_set_last_result(*error);
                        }
-                       _tbm_set_last_result(*error);
                        goto bo_alloc_fail;
                }
        } else {
@@ -474,7 +475,8 @@ tbm_bo_alloc_with_format(tbm_bufmgr bufmgr, int format, int bo_idx, int width,
                if (!bo_data) {
                        TBM_ERR("error: fail to tbm_bo_alloc_with_format fmt(%s) idx(%d) w(%d) h(%d) mem_types(%s)\n",
                                        FOURCC_STR(format), bo_idx, width, height, _tbm_flag_to_str(flags));
-                       _tbm_set_last_result(*error);
+                       if (error)
+                               _tbm_set_last_result(*error);
                        goto bo_alloc_fail;
                }
        }
@@ -534,8 +536,9 @@ tbm_bo_alloc_with_tiled_format(tbm_bufmgr bufmgr, int width, int height, int bpp
                        if (ret != HAL_TBM_ERROR_NOT_SUPPORTED) {
                                TBM_ERR("error: fail to tbm_bo_alloc_with_tiled_format fmt(%s) idx(%d) w(%d) h(%d) flags(%s)\n",
                                        FOURCC_STR(format), bo_idx, width, height, _tbm_flag_to_str(flags));
+                               if (error)
+                                       _tbm_set_last_result(*error);
                        }
-                       _tbm_set_last_result(*error);
                        goto bo_alloc_fail;
                }
        } else {
@@ -544,7 +547,8 @@ tbm_bo_alloc_with_tiled_format(tbm_bufmgr bufmgr, int width, int height, int bpp
                if (!bo_data) {
                        TBM_ERR("error: fail to tbm_bo_alloc_with_tiled_format fmt(%s) idx(%d) w(%d) h(%d) flags(%s)\n",
                                        FOURCC_STR(format), bo_idx, width, height, _tbm_flag_to_str(flags));
-                       _tbm_set_last_result(*error);
+                       if (error)
+                               _tbm_set_last_result(*error);
                        goto bo_alloc_fail;
                }
        }