[PATCH] mtd corruption fix
authorRichard Purdie <rpurdie@rpsys.net>
Sun, 27 Aug 2006 08:23:33 +0000 (01:23 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sun, 27 Aug 2006 18:01:29 +0000 (11:01 -0700)
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.

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Cc: David Woodhouse <dwmw2@infradead.org>
Acked-by: Josh Boyer <jwboyer@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/mtd/nand/nand_base.c

index 62b861304e03e92ebb40860aebd8e07c3fc9f9f1..c8cbc00243fece8bd9da98ef160e76d89e57b8ea 100644 (file)
@@ -1093,9 +1093,10 @@ static int nand_read(struct mtd_info *mtd, loff_t from, size_t len,
 
        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 *mtd, loff_t to, size_t len,
 
        ret = nand_do_write_ops(mtd, to, &chip->ops);
 
+       *retlen = chip->ops.retlen;
+
        nand_release_device(mtd);
 
-       *retlen = chip->ops.retlen;
        return ret;
 }