From: Richard Purdie Date: Sun, 27 Aug 2006 08:23:33 +0000 (-0700) Subject: [PATCH] mtd corruption fix X-Git-Tag: firefly_0821_release~33825 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7fd5aecc5d32882f8e29b14370e9ce2520e7e56f;p=firefly-linux-kernel-4.4.55.git [PATCH] mtd corruption fix 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 Cc: David Woodhouse Acked-by: Josh Boyer Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 62b861304e03..c8cbc00243fe 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -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; }