You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/01/31 13:03:03 UTC

(nuttx) 01/02: compiler/tasking: fix NULL pointer reference

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

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

commit d133de10e6d8dedaa9ed52dc4aabaaa19698ab0e
Author: chao an <an...@lixiang.com>
AuthorDate: Wed Jan 31 09:50:50 2024 +0800

    compiler/tasking: fix NULL pointer reference
    
    ctc E246: ["map/mm_map.c" 67/41] left side of '.' or '->' is not struct or union
    ctc E260: ["map/mm_map.c" 67/25] not an lvalue
    ctc E246: ["map/mm_map.c" 80/3] left side of '.' or '->' is not struct or union
    ctc E260: ["map/mm_map.c" 80/3] not an lvalue
    
    Signed-off-by: chao an <an...@lixiang.com>
---
 mm/map/mm_map.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/mm/map/mm_map.c b/mm/map/mm_map.c
index 5d89bced60..6c0261ba1a 100644
--- a/mm/map/mm_map.c
+++ b/mm/map/mm_map.c
@@ -64,7 +64,15 @@ static bool in_range(FAR const void *start, size_t length,
 
 int mm_map_lock(void)
 {
-  return nxrmutex_lock(&get_current_mm()->mm_map_mutex);
+  FAR struct tcb_s *tcb = nxsched_self();
+  FAR struct task_group_s *group = tcb->group;
+
+  if (group == NULL)
+    {
+      return -EINVAL;
+    }
+
+  return nxrmutex_lock(&group->tg_mm_map.mm_map_mutex);
 }
 
 /****************************************************************************
@@ -77,7 +85,15 @@ int mm_map_lock(void)
 
 void mm_map_unlock(void)
 {
-  DEBUGVERIFY(nxrmutex_unlock(&get_current_mm()->mm_map_mutex));
+  FAR struct tcb_s *tcb = nxsched_self();
+  FAR struct task_group_s *group = tcb->group;
+
+  if (group == NULL)
+    {
+      return;
+    }
+
+  DEBUGVERIFY(nxrmutex_unlock(&group->tg_mm_map.mm_map_mutex));
 }
 
 /****************************************************************************