]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mtd: nand: fix integer widening problems
authorBrian Norris <computersforpeace@gmail.com>
Tue, 22 Jul 2014 02:08:03 +0000 (19:08 -0700)
committerBrian Norris <computersforpeace@gmail.com>
Tue, 19 Aug 2014 18:53:09 +0000 (11:53 -0700)
chip->pagebuf is a 32-bit type (int), so the shift will only be applied
as 32-bit. Fix this for 64-bit safety.

Caught by Coverity.

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

index 1a27c2da29ffd083f936f5c61d0827789900405c..ae6e7c47f8e2668a34761d8c9f56f6eadf727712 100644 (file)
@@ -2409,8 +2409,8 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
        blockmask = (1 << (chip->phys_erase_shift - chip->page_shift)) - 1;
 
        /* Invalidate the page cache, when we write to the cached page */
-       if (to <= (chip->pagebuf << chip->page_shift) &&
-           (chip->pagebuf << chip->page_shift) < (to + ops->len))
+       if (to <= ((loff_t)chip->pagebuf << chip->page_shift) &&
+           ((loff_t)chip->pagebuf << chip->page_shift) < (to + ops->len))
                chip->pagebuf = -1;
 
        /* Don't allow multipage oob writes with offset */