summaryrefslogtreecommitdiff
path: root/drivers/mtd/tests/pagetest.c
diff options
context:
space:
mode:
authorBrian Norris <computersforpeace@gmail.com>2014-07-21 19:07:12 -0700
committerBrian Norris <computersforpeace@gmail.com>2014-08-19 11:53:08 -0700
commit1001ff7a4f64f3f4264e69d3ed70ff428f627e01 (patch)
tree9b673e00fda7873a9958cf5d60f66a49cf2e020c /drivers/mtd/tests/pagetest.c
parent8c3f3f1d7941bcb25590b784f84accd7dcb44ba3 (diff)
mtd: tests: fix integer overflow issues
These multiplications are done with 32-bit arithmetic, then converted to 64-bit. We should widen the integers first to prevent overflow. This could be a problem for large (>4GB) MTD's. Detected by Coverity. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Cc: Akinobu Mita <akinobu.mita@gmail.com>
Diffstat (limited to 'drivers/mtd/tests/pagetest.c')
-rw-r--r--drivers/mtd/tests/pagetest.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/mtd/tests/pagetest.c b/drivers/mtd/tests/pagetest.c
index ed2d3f656fd2..88296e888e9d 100644
--- a/drivers/mtd/tests/pagetest.c
+++ b/drivers/mtd/tests/pagetest.c
@@ -52,7 +52,7 @@ static struct rnd_state rnd_state;
static int write_eraseblock(int ebnum)
{
- loff_t addr = ebnum * mtd->erasesize;
+ loff_t addr = (loff_t)ebnum * mtd->erasesize;
prandom_bytes_state(&rnd_state, writebuf, mtd->erasesize);
cond_resched();
@@ -64,7 +64,7 @@ static int verify_eraseblock(int ebnum)
uint32_t j;
int err = 0, i;
loff_t addr0, addrn;
- loff_t addr = ebnum * mtd->erasesize;
+ loff_t addr = (loff_t)ebnum * mtd->erasesize;
addr0 = 0;
for (i = 0; i < ebcnt && bbt[i]; ++i)