mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] mtdraw: fix oob read and write
@ 2013-04-11 12:04 Eric Bénard
  2013-04-12 17:29 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Bénard @ 2013-04-11 12:04 UTC (permalink / raw)
  To: barebox

actually ops.ooboffs is not defaulted so when its value gets
added to chip->oob_poi in nand_fill_oob or nand_transfer_oob
the respective memcpy is using a wrong address.

With this patch, both md -s /dev/nandraw0 and cp xyz /dev/nandraw0.sb
are working fine on an i.MX28 target (instead of crashing the board).

Signed-off-by: Eric Bénard <eric@eukrea.com>
---
 drivers/mtd/mtdraw.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mtd/mtdraw.c b/drivers/mtd/mtdraw.c
index 384104e..c289e8d 100644
--- a/drivers/mtd/mtdraw.c
+++ b/drivers/mtd/mtdraw.c
@@ -98,6 +98,7 @@ static ssize_t mtdraw_read_unaligned(struct mtd_info *mtd, void *dst,
 	if (!tmp)
 		return -ENOMEM;
 	ops.mode = MTD_OOB_RAW;
+	ops.ooboffs = 0;
 	ops.datbuf = tmp;
 	ops.len = mtd->writesize;
 	ops.oobbuf = tmp + mtd->writesize;
@@ -152,6 +153,7 @@ static ssize_t mtdraw_blkwrite(struct mtd_info *mtd, const void *buf,
 	int ret;
 
 	ops.mode = MTD_OOB_RAW;
+	ops.ooboffs = 0;
 	ops.datbuf = (void *)buf;
 	ops.len = mtd->writesize;
 	ops.oobbuf = (void *)buf + mtd->writesize;
-- 
1.7.11.7


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-04-12 17:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-11 12:04 [PATCH] mtdraw: fix oob read and write Eric Bénard
2013-04-12 17:29 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox