[PATCH 2/2] mtd: rawnand: vf610_nfc: rearm the completion before starting a command
Mehmet Fide
mehmet.fide at gmail.com
Fri Aug 28 01:53:40 PDT 2026
From: Mehmet Fide <mehmet.fide at screeningeagle.com>
When a command times out, its interrupt may still arrive later and
complete cmd_done. The next command then sees the completion already
done and vf610_nfc_done() returns before the controller has finished,
so the caller reads the SRAM buffer of an unfinished transfer.
Reinitialize the completion before starting the command, so the wait
can only be satisfied by the interrupt of the command it belongs to.
Fixes: 456930d80a2d ("mtd: nand: vf610_nfc: Freescale NFC for VF610, MPC5125 and others")
Cc: stable at vger.kernel.org
Signed-off-by: Mehmet Fide <mehmet.fide at screeningeagle.com>
---
drivers/mtd/nand/raw/vf610_nfc.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/mtd/nand/raw/vf610_nfc.c b/drivers/mtd/nand/raw/vf610_nfc.c
index f831780d6fff..f88c7b45bcbc 100644
--- a/drivers/mtd/nand/raw/vf610_nfc.c
+++ b/drivers/mtd/nand/raw/vf610_nfc.c
@@ -291,6 +291,9 @@ static void vf610_nfc_done(struct vf610_nfc *nfc)
{
unsigned long timeout = msecs_to_jiffies(100);
+ /* A late interrupt of a timed-out command may have completed this already */
+ reinit_completion(&nfc->cmd_done);
+
/*
* Barrier is needed after this write. This write need
* to be done before reading the next register the first
--
2.54.0
More information about the linux-mtd
mailing list