mtd: nand: fix integer widening problems

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Wed Oct 15 23:59:04 PDT 2014


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=537ab1bd47d6518e8a40207a80dd0c2c4bc43aed
Commit:     537ab1bd47d6518e8a40207a80dd0c2c4bc43aed
Parent:     7a6f43958a53020f85818ff5c895623e88781fd6
Author:     Brian Norris <computersforpeace at gmail.com>
AuthorDate: Mon Jul 21 19:08:03 2014 -0700
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Tue Aug 19 11:53:09 2014 -0700

    mtd: nand: fix integer widening problems
    
    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 at gmail.com>
---
 drivers/mtd/nand/nand_base.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 1a27c2d..ae6e7c4 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -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 */



More information about the linux-mtd-cvs mailing list