From: Chanwoo Choi Date: Wed, 24 Aug 2022 05:29:31 +0000 (+0900) Subject: resource-monitor: Fix coverity issue X-Git-Tag: submit/tizen/20220830.033447^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8292dc63f70199454833f9a14f681b110c33dad1;p=platform%2Fcore%2Fsystem%2Fpass.git resource-monitor: Fix coverity issue Change-Id: I1df8b406efd54de3154d3e26f74b97f5f57b8160 Signed-off-by: Chanwoo Choi --- diff --git a/src/resource/resource-display.c b/src/resource/resource-display.c index bd3b203..b934f01 100644 --- a/src/resource/resource-display.c +++ b/src/resource/resource-display.c @@ -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; diff --git a/src/util/resource.c b/src/util/resource.c index 3e7b828..411cb4b 100644 --- a/src/util/resource.c +++ b/src/util/resource.c @@ -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 = diff --git a/tools/resource-monitor/resource-monitor.c b/tools/resource-monitor/resource-monitor.c index ebb64f4..ec3e073 100644 --- a/tools/resource-monitor/resource-monitor.c +++ b/tools/resource-monitor/resource-monitor.c @@ -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;