diff mbox series

mtd: rawnand: cadence: Initialize IRQ state before requesting IRQ

Message ID 20260902070542.3485515-1-runyu.xiao@seu.edu.cn
State New
Headers show
Series mtd: rawnand: cadence: Initialize IRQ state before requesting IRQ | expand

Commit Message

Runyu Xiao Sept. 2, 2026, 7:05 a.m. UTC
The Cadence NAND interrupt handler uses both the IRQ lock and completion
object. Registering the IRQ before initializing them leaves a window in
which a pending interrupt can access uninitialized synchronization state.

Initialize them before registering the handler.

Fixes: ec4ba01e894d ("mtd: rawnand: Add new Cadence NAND driver to MTD subsystem")
Cc: stable@vger.kernel.org
Assisted-by: Codex:GPT-5
Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
---
 drivers/mtd/nand/raw/cadence-nand-controller.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Miquel Raynal Sept. 4, 2026, 5:38 p.m. UTC | #1
On Wed, 02 Sep 2026 15:05:42 +0800, Runyu Xiao wrote:
> The Cadence NAND interrupt handler uses both the IRQ lock and completion
> object. Registering the IRQ before initializing them leaves a window in
> which a pending interrupt can access uninitialized synchronization state.
> 
> Initialize them before registering the handler.
> 
> 
> [...]

Applied to mtd/fixes, thanks!

[1/1] mtd: rawnand: cadence: Initialize IRQ state before requesting IRQ
      commit: c4da23777d35f4aaae7ff0ea9a503ba2702ef53c

Patche(s) should be available on mtd/linux.git and will be
part of the next PR (provided that no robot complains by then).

Kind regards,
Miquèl
diff mbox series

Patch

diff --git a/drivers/mtd/nand/raw/cadence-nand-controller.c b/drivers/mtd/nand/raw/cadence-nand-controller.c
index d53b35a8b..cff36ea3a 100644
--- a/drivers/mtd/nand/raw/cadence-nand-controller.c
+++ b/drivers/mtd/nand/raw/cadence-nand-controller.c
@@ -3143,6 +3143,9 @@  static int cadence_nand_init(struct cdns_nand_ctrl *cdns_ctrl)
 		goto free_buf_desc;
 	}
 
+	spin_lock_init(&cdns_ctrl->irq_lock);
+	init_completion(&cdns_ctrl->complete);
+
 	if (devm_request_irq(cdns_ctrl->dev, cdns_ctrl->irq, cadence_nand_isr,
 			     IRQF_SHARED, "cadence-nand-controller",
 			     cdns_ctrl)) {
@@ -3151,9 +3154,6 @@  static int cadence_nand_init(struct cdns_nand_ctrl *cdns_ctrl)
 		goto free_buf;
 	}
 
-	spin_lock_init(&cdns_ctrl->irq_lock);
-	init_completion(&cdns_ctrl->complete);
-
 	ret = cadence_nand_hw_init(cdns_ctrl);
 	if (ret)
 		goto disable_irq;