diff options
author | Yunmi Ha <yunmi.ha@samsung.com> | 2021-02-22 11:31:09 +0900 |
---|---|---|
committer | Yunmi Ha <yunmi.ha@samsung.com> | 2021-02-22 12:44:11 +0900 |
commit | a1c6ffae391b14d6368c4352ea2e066b79e048a9 (patch) | |
tree | 6039d19a15129023e67945d842ce5ffeb198049e | |
parent | 58859d19606ed1e2ac81e5bf4cd555f5826dc7e3 (diff) | |
download | device-tm1-a1c6ffae391b14d6368c4352ea2e066b79e048a9.tar.gz device-tm1-a1c6ffae391b14d6368c4352ea2e066b79e048a9.tar.bz2 device-tm1-a1c6ffae391b14d6368c4352ea2e066b79e048a9.zip |
Fix svace issues
- memory: DIVISION_BY_ZERO
- touchscreen: Resource leaks
Change-Id: I13b2570a61cbeabc236cf0717c9fd056dd17cb19
Signed-off-by: Yunmi Ha <yunmi.ha@samsung.com>
-rw-r--r-- | hw/memory/memory.c | 7 | ||||
-rw-r--r-- | hw/touchscreen/touchscreen.c | 6 |
2 files changed, 8 insertions, 5 deletions
diff --git a/hw/memory/memory.c b/hw/memory/memory.c index 45e6a5c..2defae7 100644 --- a/hw/memory/memory.c +++ b/hw/memory/memory.c @@ -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); diff --git a/hw/touchscreen/touchscreen.c b/hw/touchscreen/touchscreen.c index 319c37c..983cb8f 100644 --- a/hw/touchscreen/touchscreen.c +++ b/hw/touchscreen/touchscreen.c @@ -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; |