mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 11:26:12 +08:00
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 <dulibo1@xiaomi.com>
This commit is contained in:
@@ -137,6 +137,14 @@ int nxsched_smp_call_handler(int irq, FAR void *context,
|
|||||||
ret = call_data->func(call_data->arg);
|
ret = call_data->func(call_data->arg);
|
||||||
|
|
||||||
flags = enter_critical_section();
|
flags = enter_critical_section();
|
||||||
|
if (spin_is_locked(&call_data->lock))
|
||||||
|
{
|
||||||
|
if (--call_data->refcount == 0)
|
||||||
|
{
|
||||||
|
spin_unlock(&call_data->lock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (call_data->cookie != NULL)
|
if (call_data->cookie != NULL)
|
||||||
{
|
{
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@@ -146,14 +154,6 @@ int nxsched_smp_call_handler(int irq, FAR void *context,
|
|||||||
|
|
||||||
nxsem_post(&call_data->cookie->sem);
|
nxsem_post(&call_data->cookie->sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spin_is_locked(&call_data->lock))
|
|
||||||
{
|
|
||||||
if (--call_data->refcount == 0)
|
|
||||||
{
|
|
||||||
spin_unlock(&call_data->lock);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
up_cpu_paused_restore();
|
up_cpu_paused_restore();
|
||||||
|
|||||||
Reference in New Issue
Block a user