summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/tests/torturetest.c
diff options
context:
space:
mode:
authorBrian Norris <computersforpeace@gmail.com>2015-02-28 11:02:26 +0100
committerBrian Norris <computersforpeace@gmail.com>2015-03-11 23:21:47 +0100
commitb9da8bae416efda5ad61c7c92edbb30de15ff7ee (patch)
tree85278d8d43ad2db78971ed9de0cc08f5097c7014 /drivers/mtd/tests/torturetest.c
parentmtd: onenand: drop dead code (diff)
downloadlinux-b9da8bae416efda5ad61c7c92edbb30de15ff7ee.tar.xz
linux-b9da8bae416efda5ad61c7c92edbb30de15ff7ee.zip
mtd: tests: fix more potential integer overflows
Caught by Coverity (CID #200625 and others) Signed-off-by: Brian Norris <computersforpeace@gmail.com> Cc: Akinobu Mita <akinobu.mita@gmail.com>
Diffstat (limited to 'drivers/mtd/tests/torturetest.c')
-rw-r--r--drivers/mtd/tests/torturetest.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/mtd/tests/torturetest.c b/drivers/mtd/tests/torturetest.c
index b55bc52a1340..5045cf1b3160 100644
--- a/drivers/mtd/tests/torturetest.c
+++ b/drivers/mtd/tests/torturetest.c
@@ -101,11 +101,11 @@ static inline int check_eraseblock(int ebnum, unsigned char *buf)
{
int err, retries = 0;
size_t read;
- loff_t addr = ebnum * mtd->erasesize;
+ loff_t addr = (loff_t)ebnum * mtd->erasesize;
size_t len = mtd->erasesize;
if (pgcnt) {
- addr = (ebnum + 1) * mtd->erasesize - pgcnt * pgsize;
+ addr = (loff_t)(ebnum + 1) * mtd->erasesize - pgcnt * pgsize;
len = pgcnt * pgsize;
}
@@ -155,11 +155,11 @@ static inline int write_pattern(int ebnum, void *buf)
{
int err;
size_t written;
- loff_t addr = ebnum * mtd->erasesize;
+ loff_t addr = (loff_t)ebnum * mtd->erasesize;
size_t len = mtd->erasesize;
if (pgcnt) {
- addr = (ebnum + 1) * mtd->erasesize - pgcnt * pgsize;
+ addr = (loff_t)(ebnum + 1) * mtd->erasesize - pgcnt * pgsize;
len = pgcnt * pgsize;
}
err = mtd_write(mtd, addr, len, &written, buf);