diff options
author | Colin Ian King <colin.king@canonical.com> | 2017-11-08 16:13:23 +0000 |
---|---|---|
committer | Boris Brezillon <boris.brezillon@free-electrons.com> | 2017-12-18 13:30:04 +0100 |
commit | b1d030f804fbf8f502756231d475fcf8fd6a86ad (patch) | |
tree | d3114c6ab32e1e67840f5cfb0ae0104886deb9bc /drivers/mtd/parsers | |
parent | 9e343e87d2c4c707ef8fae2844864d4dde3a2d13 (diff) | |
download | linux-stable-b1d030f804fbf8f502756231d475fcf8fd6a86ad.tar.gz linux-stable-b1d030f804fbf8f502756231d475fcf8fd6a86ad.tar.bz2 linux-stable-b1d030f804fbf8f502756231d475fcf8fd6a86ad.zip |
mtd: sharpslpart: fix overflow on block_adr calculation
Multiplying block_num and mtd->erasesize may potentially overflow
as they are both unsigned ints and so the multiplication is evaluated
in unsigned int arithmetic. Cast block_adr to off_t to ensure
multiplication is off_t sized to avoid any potential overflow.
Detected by CoverityScan, CID#1461264 ("Unintentional integer overflow")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Andrea Adami <andrea.adami@gmail.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Diffstat (limited to 'drivers/mtd/parsers')
-rw-r--r-- | drivers/mtd/parsers/sharpslpart.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/mtd/parsers/sharpslpart.c b/drivers/mtd/parsers/sharpslpart.c index 5fe0079ea5ed..0ddb79ac390d 100644 --- a/drivers/mtd/parsers/sharpslpart.c +++ b/drivers/mtd/parsers/sharpslpart.c @@ -192,7 +192,7 @@ static int sharpsl_nand_init_ftl(struct mtd_info *mtd, struct sharpsl_ftl *ftl) /* create physical-logical table */ for (block_num = 0; block_num < phymax; block_num++) { - block_adr = block_num * mtd->erasesize; + block_adr = (loff_t)block_num * mtd->erasesize; if (mtd_block_isbad(mtd, block_adr)) continue; @@ -244,7 +244,7 @@ static int sharpsl_nand_read_laddr(struct mtd_info *mtd, return -EINVAL; block_num = ftl->log2phy[log_num]; - block_adr = block_num * mtd->erasesize; + block_adr = (loff_t)block_num * mtd->erasesize; block_ofs = mtd_mod_by_eb((u32)from, mtd); err = mtd_read(mtd, block_adr + block_ofs, len, &retlen, buf); |