Skip to contentSkip to conversation

mtdraw: fix oob read and write

PATCH Applied Eric Bénard 2 participants 2 messages Apr 11, 2013 – Apr 12, 2013 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtdraw: fix oob read and write

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).

---
 drivers/mtd/mtdraw.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mtd/mtdraw.c +2 -0
index 384104e..c289e8d 100644
@@ -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;
Signature · 7 lines
1.7.11.7


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#1 lore raw
Quoted 8 lines · Eric Bénard

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).

Applied, thanks

Sascha

Quoted 32 lines
---
 drivers/mtd/mtdraw.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mtd/mtdraw.c +2 -0
index 384104e..c289e8d 100644
@@ -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;
Signature · 7 lines
1.7.11.7


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox