Skip to contentSkip to conversation

mtd: mtdswap: fix integer overflow

PATCH New Brian Norris 1 participant 1 message Jul 22, 2014 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: mtdswap: fix integer overflow

Caught by Coverity.

---
 drivers/mtd/mtdswap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/mtdswap.c +1 -1
index 8b33b26eb12b..8ca8d41bb35e 100644
@@ -1474,7 +1474,7 @@ static void mtdswap_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
 	}
 
 	eblocks = mtd_div_by_eb(use_size, mtd);
-	use_size = eblocks * mtd->erasesize;
+	use_size = (uint64_t)eblocks * mtd->erasesize;
 	bad_blocks = mtdswap_badblocks(mtd, use_size);
 	eavailable = eblocks - bad_blocks;
 
Signature · 1 line
1.9.1