cpuload: fix crash because of the member of g_pidhash is NULL

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
Jiuzhu Dong
2021-10-18 19:40:06 +08:00
committed by Alin Jerpelea
parent 3e1ce5f770
commit 7e59a6a31e
+5 -2
View File
@@ -184,8 +184,11 @@ void weak_function nxsched_process_cpuload(void)
for (i = 0; i < g_npidhash; i++) for (i = 0; i < g_npidhash; i++)
{ {
g_pidhash[i]->ticks >>= 1; if (g_pidhash[i])
total += g_pidhash[i]->ticks; {
g_pidhash[i]->ticks >>= 1;
total += g_pidhash[i]->ticks;
}
} }
/* Save the new total. */ /* Save the new total. */