This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch releases/12.7 in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 755bef6c5699ea4cc99cb40185fe2cb5b58c9385 Author: dulibo1 <[email protected]> AuthorDate: Wed Apr 17 17:42:51 2024 +0800 sched_smp:adjust the unlock order 1.nxsem_post wake up nxsched_smp_call; 2.stack smp_call_data_s may return; 3.nxsched_smp_call_handler access call_data->lock is not safety; so adjust the unlock order Signed-off-by: dulibo1 <[email protected]> --- sched/sched/sched_smp.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sched/sched/sched_smp.c b/sched/sched/sched_smp.c index f43cb08ac7..94aab39130 100644 --- a/sched/sched/sched_smp.c +++ b/sched/sched/sched_smp.c @@ -137,22 +137,22 @@ int nxsched_smp_call_handler(int irq, FAR void *context, ret = call_data->func(call_data->arg); flags = enter_critical_section(); - if (call_data->cookie != NULL) + if (spin_is_locked(&call_data->lock)) { - if (ret < 0) + if (--call_data->refcount == 0) { - call_data->cookie->error = ret; + spin_unlock(&call_data->lock); } - - nxsem_post(&call_data->cookie->sem); } - if (spin_is_locked(&call_data->lock)) + if (call_data->cookie != NULL) { - if (--call_data->refcount == 0) + if (ret < 0) { - spin_unlock(&call_data->lock); + call_data->cookie->error = ret; } + + nxsem_post(&call_data->cookie->sem); } }
