mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 23:03:27 +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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spin_unlock_irqrestore(&g_irqchainlock, flags);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
spin_unlock_irqrestore(&g_irqchainlock, flags);
|
||||||
ret = irq_detach(irq);
|
ret = irq_detach(irq);
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_unlock_irqrestore(&g_irqchainlock, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user