Fix coverity issue 35/224535/2
authorYoungjae Cho <y0.cho@samsung.com>
Tue, 11 Feb 2020 08:53:57 +0000 (17:53 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Tue, 11 Feb 2020 09:14:15 +0000 (09:14 +0000)
CID 1099199 (#1 of 1): Read from pointer after free (USE_AFTER_FREE)
20. deref_after_free: Dereferencing freed pointer elem.

Change-Id: I85c34f351db0cc10ce384176b90ba72067e3c051
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/cpu/pmqos.c

index ff483d8..c2bbcda 100644 (file)
@@ -77,7 +77,7 @@ int set_cpu_pmqos(const char *name, int val)
 
 static void pmqos_unlock_timeout_update(void)
 {
-       dd_list *elem;
+       dd_list *elem, *elem_next;
        struct pmqos_cpu *cpu;
        int delta = 0;
 
@@ -98,7 +98,7 @@ static void pmqos_unlock_timeout_update(void)
                /* Delete previous request */
        }
 
-       DD_LIST_FOREACH(pmqos_head, elem, cpu) {
+       DD_LIST_FOREACH_SAFE(pmqos_head, elem, elem_next, cpu) {
                if (cpu->timeout > 0)
                        continue;
                DD_LIST_REMOVE(pmqos_head, cpu);