mtd: brcmnand: Fix pointer type-cast in brcmnand_write()

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Nov 6 10:59:11 PST 2015


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=3f08b8ba9f5d7ec528a9fc293e76a14c2851e403
Commit:     3f08b8ba9f5d7ec528a9fc293e76a14c2851e403
Parent:     06968a54790d9dd87a5bb68e8197b5094eff63c3
Author:     Anup Patel <anup.patel at broadcom.com>
AuthorDate: Fri Oct 2 23:26:42 2015 +0530
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Mon Oct 12 14:17:30 2015 -0700

    mtd: brcmnand: Fix pointer type-cast in brcmnand_write()
    
    We should always type-cast pointer to "long" or "unsigned long"
    because size of pointer is same as machine word size. This will
    avoid pointer type-cast issues on both 32bit and 64bit systems.
    
    This patch fixes pointer type-cast issue in brcmnand_write()
    as-per above info.
    
    Signed-off-by: Anup Patel <anup.patel at broadcom.com>
    Reviewed-by: Vikram Prakash <vikramp at broadcom.com>
    Reviewed-by: Ray Jui <rjui at broadcom.com>
    Reviewed-by: Scott Branden <sbranden at broadcom.com>
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
 drivers/mtd/nand/brcmnand/brcmnand.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/brcmnand/brcmnand.c b/drivers/mtd/nand/brcmnand/brcmnand.c
index 048e4e0..ea319a4 100644
--- a/drivers/mtd/nand/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/brcmnand/brcmnand.c
@@ -1544,9 +1544,9 @@ static int brcmnand_write(struct mtd_info *mtd, struct nand_chip *chip,
 
 	dev_dbg(ctrl->dev, "write %llx <- %p\n", (unsigned long long)addr, buf);
 
-	if (unlikely((u32)buf & 0x03)) {
+	if (unlikely((unsigned long)buf & 0x03)) {
 		dev_warn(ctrl->dev, "unaligned buffer: %p\n", buf);
-		buf = (u32 *)((u32)buf & ~0x03);
+		buf = (u32 *)((unsigned long)buf & ~0x03);
 	}
 
 	brcmnand_wp(mtd, 0);



More information about the linux-mtd-cvs mailing list