mtd: mtdswap: fix integer overflow
authorBrian Norris <computersforpeace@gmail.com>
Tue, 22 Jul 2014 02:07:02 +0000 (19:07 -0700)
committerBrian Norris <computersforpeace@gmail.com>
Tue, 19 Aug 2014 18:53:08 +0000 (11:53 -0700)
Caught by Coverity.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
drivers/mtd/mtdswap.c

index 0ec96cd..48cf6f9 100644 (file)
@@ -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;