Skip to contentSkip to conversation

mtd: mtdraw: Fix cdev size calculation for large NANDs

PATCH Applied Yunus Bas 2 participants 2 messages May 4, 2020 – May 5, 2020 Memory technology devices (MTD)

lore
Share & tools
lore

Yunus Bas

author
#0 lore raw

PATCH 1/1 mtd: mtdraw: Fix cdev size calculation for large NANDs

From: Stefan Riedmueller <[email protected]>

Raw size for large NAND devices (> 4 GB) can exceed 32 bits, so we need 64 bit types as factors. Both factors are of 32 bit types, as such is the return value. At least one factor needs to be 64 bit type when calculating the size.

---
 drivers/mtd/mtdraw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/mtdraw.c +1 -1
index f63da7b..b716192 100644
@@ -306,7 +306,7 @@ static int add_mtdraw_device(struct mtd_info *mtd, const char *devname, void **p
 	mtdraw->mtd = mtd;
 
 	mtdraw->cdev.ops = (struct cdev_operations *)&mtd_raw_fops;
-	mtdraw->cdev.size = mtd_div_by_wb(mtd->size, mtd) * mtdraw->rps;
+	mtdraw->cdev.size = (loff_t)mtd_div_by_wb(mtd->size, mtd) * mtdraw->rps;
 	mtdraw->cdev.name = basprintf("%s.raw", mtd->cdev.name);
 	mtdraw->cdev.priv = mtdraw;
 	mtdraw->cdev.dev = &mtd->class_dev;
Signature · 7 lines
2.7.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#1 lore raw
Quoted 7 lines · Yunus Bas

From: Stefan Riedmueller <[email protected]>

Raw size for large NAND devices (> 4 GB) can exceed 32 bits, so we need 64 bit types as factors. Both factors are of 32 bit types, as such is the return value. At least one factor needs to be 64 bit type when calculating the size.

Quoted 6 lines
---
 drivers/mtd/mtdraw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks

Sascha

Quoted 23 lines
drivers/mtd/mtdraw.c +1 -1
index f63da7b..b716192 100644
@@ -306,7 +306,7 @@ static int add_mtdraw_device(struct mtd_info *mtd, const char *devname, void **p
 	mtdraw->mtd = mtd;
 
 	mtdraw->cdev.ops = (struct cdev_operations *)&mtd_raw_fops;
-	mtdraw->cdev.size = mtd_div_by_wb(mtd->size, mtd) * mtdraw->rps;
+	mtdraw->cdev.size = (loff_t)mtd_div_by_wb(mtd->size, mtd) * mtdraw->rps;
 	mtdraw->cdev.name = basprintf("%s.raw", mtd->cdev.name);
 	mtdraw->cdev.priv = mtdraw;
 	mtdraw->cdev.dev = &mtd->class_dev;
Signature · 7 lines
2.7.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
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