You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by je...@apache.org on 2021/10/18 13:14:48 UTC

[incubator-nuttx] branch master updated: cpuload: fix crash because of the member of g_pidhash is NULL

This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 7e59a6a  cpuload: fix crash because of the member of g_pidhash is NULL
7e59a6a is described below

commit 7e59a6a31eca6642c3c4c0611a69ee500b840f8a
Author: Jiuzhu Dong <do...@xiaomi.com>
AuthorDate: Mon Oct 18 19:40:06 2021 +0800

    cpuload: fix crash because of the member of g_pidhash is NULL
    
    Signed-off-by: Jiuzhu Dong <do...@xiaomi.com>
---
 sched/sched/sched_cpuload.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/sched/sched/sched_cpuload.c b/sched/sched/sched_cpuload.c
index 1f3fac3..de841de 100644
--- a/sched/sched/sched_cpuload.c
+++ b/sched/sched/sched_cpuload.c
@@ -184,8 +184,11 @@ void weak_function nxsched_process_cpuload(void)
 
       for (i = 0; i < g_npidhash; i++)
         {
-          g_pidhash[i]->ticks >>= 1;
-          total += g_pidhash[i]->ticks;
+          if (g_pidhash[i])
+            {
+              g_pidhash[i]->ticks >>= 1;
+              total += g_pidhash[i]->ticks;
+            }
         }
 
       /* Save the new total. */