From: Jeongmo Yang Date: Thu, 5 Jun 2025 02:27:51 +0000 (+0900) Subject: Fix coverity issues X-Git-Tag: accepted/tizen/unified/20250610.081745^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9c01988e8bddfbcc84c3f16f5d21619d87ef9a73;p=platform%2Fhal%2Fbackend%2Fcodec-v4l2.git Fix coverity issues - Data race condition - Resource leak [Version] 1.1.1 [Issue Type] coverity Change-Id: I73d2b2a0a227692cd347f59e6cb6aa0d8c72f4e4 Signed-off-by: Jeongmo Yang --- diff --git a/packaging/hal-backend-codec-v4l2.spec b/packaging/hal-backend-codec-v4l2.spec index 2794db9..d203593 100644 --- a/packaging/hal-backend-codec-v4l2.spec +++ b/packaging/hal-backend-codec-v4l2.spec @@ -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 diff --git a/src/hal_backend_codec_v4l2.c b/src/hal_backend_codec_v4l2.c index bf678bb..0c67ad0 100644 --- a/src/hal_backend_codec_v4l2.c +++ b/src/hal_backend_codec_v4l2.c @@ -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;