Fix coverity issues 15/321615/2 accepted/tizen/unified/20250327.154211 accepted/tizen/unified/x/20250327.215015
authorJeongmo Yang <jm80.yang@samsung.com>
Wed, 26 Mar 2025 01:13:24 +0000 (10:13 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Wed, 26 Mar 2025 01:15:17 +0000 (10:15 +0900)
- Resource leak
- Dereference after null check
- Waiting while holding a lock

[Version] 1.1.3
[Issue Type] Coverity

Change-Id: Id7217ec7a678b50e756d40fe79375da987b4987d
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/hal-api-codec.spec
src/hal-api-codec-ipc.c
tests/codec_hal_test.cpp

index 6df6a3625f2b74b88b40c6fca8b9afb708094289..a1779c476c9cf22ca658c8f2dca8c42a986a48d7 100644 (file)
@@ -6,7 +6,7 @@
 ### main package #########
 Name:       %{name}
 Summary:    %{name} interface
-Version:    1.1.2
+Version:    1.1.3
 Release:    0
 Group:      Development/Libraries
 License:    Apache-2.0
index 17a1f0dbc3a11672239cdfbaba7dec97f267cd4c..2c15074c1f9bd410b6de6bc8e1d7e1e2f5caf643 100644 (file)
@@ -261,7 +261,11 @@ static void __hal_codec_ipc_message_cb(void *user_data, bundle *b_msg, rpc_port_
                SLOGD(">>>>> msg cb: type[%d]", hal_message->type);
                ((hal_codec_message_cb)handle->msg_cb)(hal_message, handle->msg_cb_data);
                SLOGD("<<<<< msg cb: type[%d]", hal_message->type);
+
+               g_mutex_unlock(&handle->msg_lock);
        } else {
+               g_mutex_unlock(&handle->msg_lock);
+
                SLOGW("no msg cb for handle[%p]", handle);
 
                if (hal_message->type == HAL_CODEC_MESSAGE_TYPE_OUTPUT_BUFFER) {
@@ -270,8 +274,6 @@ static void __hal_codec_ipc_message_cb(void *user_data, bundle *b_msg, rpc_port_
                }
        }
 
-       g_mutex_unlock(&handle->msg_lock);
-
 _CODEC_IPC_MESSAGE_CB_DONE:
        for (i = 0 ; i < fd_size && fd ; i++) {
                /* error case */
index 7b98dfc0b8ee4f06c7485e22ae2674b3e238854c..706e861a23dc85180467df2d89975b7268d72244 100644 (file)
@@ -89,8 +89,13 @@ class CodecHalTest : public testing::Test
                {
                        static int dumpCount = 0;
 
-                       if (!buffer || !dumpPath) {
-                               cout << "DumpBuffer : buffer[" << buffer << "], path[" << dumpPath << "]" << endl;
+                       if (!buffer) {
+                               cout << "DumpBuffer : No buffer" << endl;
+                               return;
+                       }
+
+                       if (!dumpPath) {
+                               cout << "DumpBuffer : No path" << endl;
                                return;
                        }
 
@@ -143,12 +148,10 @@ class CodecHalTest : public testing::Test
 
                int GetContents(const char *path)
                {
-                       GError *error = nullptr;
-
                        if (mappedFile_)
                                g_mapped_file_unref(mappedFile_);
 
-                       mappedFile_ = g_mapped_file_new(path, FALSE, &error);
+                       mappedFile_ = g_mapped_file_new(path, FALSE, nullptr);
                        if (!mappedFile_) {
                                cout << "Codec HAL : get contents[" << path << "] failed" << endl;
                                return -1;
@@ -322,7 +325,7 @@ TEST_F(CodecHalTest, StartStopP)
        ret = hal_codec_configure(gHalHandle, 1920, 1080, HAL_CODEC_FORMAT_H264, HAL_CODEC_FORMAT_NV12, false);
        ASSERT_EQ(ret, HAL_CODEC_ERROR_NONE);
 
-       ret = hal_codec_start(gHalHandle, CodecHalTest::MessageCb, NULL);
+       ret = hal_codec_start(gHalHandle, CodecHalTest::MessageCb, nullptr);
        ASSERT_EQ(ret, HAL_CODEC_ERROR_NONE);
 
        usleep(100000);
@@ -366,7 +369,7 @@ TEST_F(CodecHalTest, DecodeP)
        ret = GetContents(CONTENTS_H264_PATH);
        ASSERT_EQ(ret, 0);
 
-       mainLoop_ = g_main_loop_new(NULL, TRUE);
+       mainLoop_ = g_main_loop_new(nullptr, TRUE);
 
        feedCount_ = 0;
        decodedCount_ = 0;