Fix coverity issues 28/325228/1 accepted/tizen_unified accepted/tizen_unified_x tizen accepted/tizen/unified/20250610.081745 accepted/tizen/unified/x/20250610.082514
authorJeongmo Yang <jm80.yang@samsung.com>
Thu, 5 Jun 2025 02:27:51 +0000 (11:27 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Thu, 5 Jun 2025 02:29:08 +0000 (11:29 +0900)
- Data race condition
- Resource leak

[Version] 1.1.1
[Issue Type] coverity

Change-Id: I73d2b2a0a227692cd347f59e6cb6aa0d8c72f4e4
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/hal-backend-codec-v4l2.spec
src/hal_backend_codec_v4l2.c

index 2794db90f4ee50933252f38d3368ee70ac7ed227..d2035932529cfa47fa653bdb31be9fd8f1e564fe 100644 (file)
@@ -1,6 +1,6 @@
 Name:       hal-backend-codec-v4l2
 Summary:    Tizen Codec HAL using generic V4L2 interface
-Version:    1.1.0
+Version:    1.1.1
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index bf678bb3825f23782a356cf9225948b8483dee6c..0c67ad084136da7e9d399cabf07c1657ad4cac9c 100644 (file)
@@ -1884,7 +1884,8 @@ int codec_v4l2_configure(void *codec_handle, int width, int height,
 
                if (__codec_v4l2_subscribe_event(device_fd, V4L2_EVENT_SOURCE_CHANGE, input_id) != HAL_CODEC_ERROR_NONE) {
                        LOGW("subscribe event[SOURCE_CHANGE] failed");
-                       return HAL_CODEC_ERROR_DEVICE_READ;
+                       ret = HAL_CODEC_ERROR_DEVICE_READ;
+                       goto _CONFIGURE_FAILED;
                }
 
                in_memory = V4L2_MEMORY_MMAP;
@@ -1901,13 +1902,12 @@ int codec_v4l2_configure(void *codec_handle, int width, int height,
                in_buf_type, in_memory, in_format, width, height,
                in_max_resolution.width, in_max_resolution.height);
        if (ret != HAL_CODEC_ERROR_NONE)
-               return ret;
+               goto _CONFIGURE_FAILED;
 
        ret = __codec_v4l2_s_fmt(buffer_control, device_fd);
        if (ret != HAL_CODEC_ERROR_NONE) {
                LOGE("set format[%d] for input failed - [0x%x]", in_format, ret);
-               close(device_fd);
-               return ret;
+               goto _CONFIGURE_FAILED;
        }
 
        /* set format for output */
@@ -1917,13 +1917,12 @@ int codec_v4l2_configure(void *codec_handle, int width, int height,
                out_buf_type, out_memory, out_format, width, height,
                out_max_resolution.width, out_max_resolution.height);
        if (ret != HAL_CODEC_ERROR_NONE)
-               return ret;
+               goto _CONFIGURE_FAILED;
 
        ret = __codec_v4l2_s_fmt(buffer_control, device_fd);
        if (ret != HAL_CODEC_ERROR_NONE) {
                LOGE("set format[%d] for output failed - [0x%x]", out_format, ret);
-               close(device_fd);
-               return ret;
+               goto _CONFIGURE_FAILED;
        }
 
        handle->is_secure = is_secure;
@@ -1933,6 +1932,10 @@ int codec_v4l2_configure(void *codec_handle, int width, int height,
        LOGD("done - secure[%d]", is_secure);
 
        return HAL_CODEC_ERROR_NONE;
+
+_CONFIGURE_FAILED:
+       close(device_fd);
+       return ret;
 }
 
 
@@ -2225,10 +2228,10 @@ int codec_v4l2_start(void *codec_handle, hal_codec_message_cb callback, void *us
                return HAL_CODEC_ERROR_INVALID_PARAMETER;
        }
 
-       LOGI("state[%d]", handle->state);
-
        locker = g_mutex_locker_new(&handle->lock);
 
+       LOGI("state[%d]", handle->state);
+
        if (handle->state != HAL_CODEC_STATE_CONFIGURED) {
                LOGE("invalid state %d", handle->state);
                return HAL_CODEC_ERROR_INVALID_STATE;
@@ -2279,10 +2282,10 @@ int codec_v4l2_stop(void *codec_handle)
                return HAL_CODEC_ERROR_INVALID_PARAMETER;
        }
 
-       LOGI("state[%d]", handle->state);
-
        locker = g_mutex_locker_new(&handle->lock);
 
+       LOGI("state[%d]", handle->state);
+
        if (handle->state != HAL_CODEC_STATE_STARTED) {
                LOGE("invalid state %d", handle->state);
                ret = HAL_CODEC_ERROR_INVALID_STATE;