Fix svace issues
authorYunmi Ha <yunmi.ha@samsung.com>
Mon, 22 Feb 2021 02:31:09 +0000 (11:31 +0900)
committerYunmi Ha <yunmi.ha@samsung.com>
Mon, 22 Feb 2021 03:44:11 +0000 (12:44 +0900)
 - memory: DIVISION_BY_ZERO
 - touchscreen: Resource leaks

Change-Id: I13b2570a61cbeabc236cf0717c9fd056dd17cb19
Signed-off-by: Yunmi Ha <yunmi.ha@samsung.com>
hw/memory/memory.c
hw/touchscreen/touchscreen.c

index 45e6a5c..2defae7 100644 (file)
@@ -74,8 +74,11 @@ static int memory_get_gem_info(const int pid, struct gem_info *info)
        temp = total_rss / (unsigned long)BYTES_PER_KBYTE;
        info->rss = (int)temp;
 
-       temp = (total_rss / (unsigned long)total_hcount) / (unsigned long)BYTES_PER_KBYTE;
-       info->pss = (int)temp;
+       if (total_hcount > 0) {
+               temp = (total_rss / (unsigned long)total_hcount) / (unsigned long)BYTES_PER_KBYTE;
+               info->pss = (int)temp;
+       } else
+               info->pss = 0;
 
        fclose(fp);
 
index 319c37c..983cb8f 100644 (file)
@@ -140,13 +140,13 @@ static int touchscreen_init(void **data)
 {
        hal_backend_touchscreen_funcs *touchscreen_funcs;
 
+       if (touchscreen_probe() < 0)
+               return -ENOTSUP;
+
        touchscreen_funcs = calloc(1, sizeof(hal_backend_touchscreen_funcs));
        if (!touchscreen_funcs)
                return -ENOMEM;
 
-       if (touchscreen_probe() < 0)
-               return -ENOTSUP;
-
        touchscreen_funcs->get_state = touchscreen_get_state;
        touchscreen_funcs->set_state = touchscreen_set_state;