Add missing release code 23/255423/2 accepted/tizen/unified/20210322.150802 submit/tizen/20210319.063415
authorJeongmo Yang <jm80.yang@samsung.com>
Thu, 18 Mar 2021 06:49:31 +0000 (15:49 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Thu, 18 Mar 2021 07:52:18 +0000 (16:52 +0900)
[Version] 0.0.3
[Issue Type] Bug fix

Change-Id: I71a2d3a276a5285f176e8d76ba0294ac0c0ffbbc
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/hal-api-camera.spec
src/hal-api-camera.c

index 4fbe4e84254a6a44101a31f9e5954dcba0f61928..f0da78d6d4210f84e1a2b8f0a8c59278e7c96ac0 100644 (file)
@@ -4,7 +4,7 @@
 ### main package #########
 Name:       %{name}
 Summary:    %{name} interface
-Version:    0.0.2
+Version:    0.0.3
 Release:    0
 Group:      Development/Libraries
 License:    Apache-2.0
index 4a60148195af7b42c3bc73827217735eb8140740..2ae417e762564a2c32b5d842f94fef13642ddc73 100644 (file)
@@ -68,23 +68,31 @@ int hal_camera_init(const char *hal_name, void **camera_handle)
        ret = hal_common_get_backend(HAL_MODULE_CAMERA, (void **)&new_handle->funcs);
        if (ret != TIZEN_ERROR_NONE) {
                SLOGE("Failed to get backend");
-               g_free(new_handle);
-               return CAMERA_ERROR_INTERNAL;
+               goto __HAL_INIT_FAILED;
        }
 
-       HAL_CAMERA_DO_RETURN_IF_FAILED(new_handle->funcs, g_free(new_handle), CAMERA_ERROR_NOT_IMPLEMENTED);
-       HAL_CAMERA_DO_RETURN_IF_FAILED(new_handle->funcs->init, g_free(new_handle), CAMERA_ERROR_NOT_IMPLEMENTED);
+       if (!new_handle->funcs || !new_handle->funcs->init) {
+               SLOGE("invalid ptr[%p]", new_handle->funcs);
+               goto __HAL_INIT_FAILED;
+       }
 
        ret = new_handle->funcs->init(&new_handle->backend);
        if (ret != CAMERA_ERROR_NONE) {
                SLOGE("backend init failed[0x%x]", ret);
-               g_free(new_handle);
-               return CAMERA_ERROR_INTERNAL;
+               goto __HAL_INIT_FAILED;
        }
 
        *camera_handle = (void *)new_handle;
 
        return CAMERA_ERROR_NONE;
+
+__HAL_INIT_FAILED:
+       if (new_handle->funcs)
+               hal_common_put_backend(HAL_MODULE_CAMERA, (void *)new_handle->funcs);
+
+       g_free(new_handle);
+
+       return CAMERA_ERROR_INTERNAL;
 }