From d133de10e6d8dedaa9ed52dc4aabaaa19698ab0e Mon Sep 17 00:00:00 2001 From: chao an Date: Wed, 31 Jan 2024 09:50:50 +0800 Subject: [PATCH] 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 --- 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 5d89bced601..6c0261ba1ab 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)); } /****************************************************************************