From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brian Norris Subject: Re: [PATCH 1/5] mtd: brcmnand: Fix pointer type-cast in brcmnand_write() Date: Mon, 12 Oct 2015 14:20:15 -0700 Message-ID: <20151012212015.GO107187@google.com> References: <1443808606-21203-1-git-send-email-anup.patel@broadcom.com> <1443808606-21203-2-git-send-email-anup.patel@broadcom.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <1443808606-21203-2-git-send-email-anup.patel-dY08KVG/lbpWk0Htik3J/w@public.gmane.org> Sender: devicetree-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Anup Patel Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Catalin Marinas , Will Deacon , David Woodhouse , Ray Jui , Scott Branden , Florian Fainelli , Pramod KUMAR , Vikram Prakash , Sandeep Tripathy , devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/w@public.gmane.org List-Id: devicetree@vger.kernel.org On Fri, Oct 02, 2015 at 11:26:42PM +0530, Anup Patel wrote: > 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 > Reviewed-by: Vikram Prakash > Reviewed-by: Ray Jui > Reviewed-by: Scott Branden > --- > 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 fddb795..4cba03d 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); > } Hmm, this block isn't really good. We should probably work to remove this. Not sure why I left that in, actually. At a minimum, it'd probably good to make this noisier, so if we see this in practice, we can work to fix those cases. But anyway, the patch is good (though 'uintptr_t' might be slightly better), so pushed to l2-mtd.git. Brian > > brcmnand_wp(mtd, 0); > -- > 1.9.1 > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html