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
+3
View File
@@ -183,10 +183,13 @@ void weak_function nxsched_process_cpuload(void)
*/ */
for (i = 0; i < g_npidhash; i++) for (i = 0; i < g_npidhash; i++)
{
if (g_pidhash[i])
{ {
g_pidhash[i]->ticks >>= 1; g_pidhash[i]->ticks >>= 1;
total += g_pidhash[i]->ticks; total += g_pidhash[i]->ticks;
} }
}
/* Save the new total. */ /* Save the new total. */