Skip to contentSkip to conversation

Protect chip->ops with correct locking - fix jffs2 corruption

PATCH New Richard Purdie 1 participant 1 message Aug 21, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Protect chip->ops with correct locking - fix jffs2 corruption

Read the return value before we release the nand device otherwise the value can become corrupted by another user of chip->ops, ultimately resulting in filesystem corruption.

---

This fixes the jffs2 errors and filesystem corruption I reported. It should be applied for 2.6.18.

Quoted 8 lines · Greg KH
Quoted 4 lines · Josh Boyer

We have multiple confirmations that this patch fixes the issue reported. I agree it should go in 2.6.18.

Greg, can you add this to your tree?

Add what to what tree? I need things to be a bit more specific here :)

 drivers/mtd/nand/nand_base.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mtd/nand/nand_base.c +4 -2
Index: git/drivers/mtd/nand/nand_base.c
===================================================================
@@ -1093,9 +1093,10 @@ static int nand_read(struct mtd_info *mt
 
 	ret = nand_do_read_ops(mtd, from, &chip->ops);
 
+	*retlen = chip->ops.retlen;
+
 	nand_release_device(mtd);
 
-	*retlen = chip->ops.retlen;
 	return ret;
 }
 
@@ -1691,9 +1692,10 @@ static int nand_write(struct mtd_info *m
 
 	ret = nand_do_write_ops(mtd, to, &chip->ops);
 
+	*retlen = chip->ops.retlen;
+
 	nand_release_device(mtd);
 
-	*retlen = chip->ops.retlen;
 	return ret;
 }