mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
sched/irq: Fix potential deadlock in irqchain_detach
Release g_irqchainlock before calling irq_detach to avoid holding two locks simultaneously, which can cause thread deadlock. The irqchain_detach function was calling irq_detach while holding g_irqchainlock, and irq_detach attempts to acquire g_irqlock. This lock ordering violation could lead to deadlock in multithreaded scenarios. Fix: - Move spin_unlock_irqrestore(&g_irqchainlock, flags) before irq_detach call - Ensure locks are released in proper order to prevent circular wait This is part of the irq_chain_lock feature for safer IRQ chain handling. Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
This commit is contained in:
@@ -257,13 +257,14 @@ int irqchain_detach(int irq, xcpt_t isr, FAR void *arg)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&g_irqchainlock, flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
spin_unlock_irqrestore(&g_irqchainlock, flags);
|
||||
ret = irq_detach(irq);
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&g_irqchainlock, flags);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user