resource-monitor: Fix coverity issue 12/280112/3 submit/tizen/20220830.033447
authorChanwoo Choi <cw00.choi@samsung.com>
Wed, 24 Aug 2022 05:29:31 +0000 (14:29 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Tue, 30 Aug 2022 03:07:49 +0000 (03:07 +0000)
Change-Id: I1df8b406efd54de3154d3e26f74b97f5f57b8160
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
src/resource/resource-display.c
src/util/resource.c
tools/resource-monitor/resource-monitor.c

index bd3b2034f676238a54a278baf56cb3c4dd2c500b..b934f010811660af75b41943b870541a41cd1e1e 100644 (file)
@@ -299,6 +299,9 @@ static int display_init(void)
        int ret;
 
        g_fps_monitor.resource_count = get_resource_device_count(RESOURCE_TYPE_DISPLAY);
+       if (g_fps_monitor.resource_count < 0)
+               return g_fps_monitor.resource_count;
+
        g_fps_monitor.last_fps = calloc(g_fps_monitor.resource_count, sizeof(double));
        if (!g_fps_monitor.last_fps)
                return -ENOMEM;
index 3e7b828e8c41f1df33762568c6a63ee4d0122ee7..411cb4b2525cff2a3e18ebdc68a0e1b9b01cdd23 100644 (file)
@@ -150,6 +150,9 @@ int add_resource_device(struct resource_device *device)
                return -EINVAL;
 
        count = get_resource_device_count(device->type);
+       if (count < 0)
+               return count;
+
        device->index = count;
 
        g_resource_device_head =
index ebb64f476678868b5c7c20f321048e5102b9ebd3..ec3e073d1cfc4533c35f9b06ca0e4663e9d75410 100644 (file)
@@ -309,7 +309,7 @@ static inline int get_resource_attr_array_value(struct resource_data *res, int i
                                res->mon_id, res->res_id,
                                res->attrs[idx].id, &array, &length);
 
-               if (ret < 0) break;
+               if (ret < 0 || length < 0) break;
 
                memset(buf, 0, BUFF_MAX + 1);
                for (i = 0; i < length; i++) {
@@ -465,6 +465,9 @@ static int resource_monitor_init(void)
 
        /* 1. Initialize resource-monitor */
        id = pass_resource_monitor_init();
+       if (id < 0)
+               return id;
+
        g_data.mon_id = id;
 
        /* 2. Get resource count */
@@ -477,6 +480,9 @@ static int resource_monitor_init(void)
                                continue;
                }
 
+               if (count < 0)
+                       continue;
+
                if (g_resource_type[i].ctrl_val < 0)
                        continue;