Skip to content

Commit

Permalink
[PATCH] mtd corruption fix
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
rpurdie authored and Linus Torvalds committed Aug 27, 2006
1 parent 6946bd6 commit 7fd5aec
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/mtd/nand/nand_base.c
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 7fd5aec

Please sign in to comment.