From: computersforpeace@gmail•com (Brian Norris)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH 1/5] mtd: brcmnand: Fix pointer type-cast in brcmnand_write()
Date: Mon, 12 Oct 2015 14:20:15 -0700 [thread overview]
Message-ID: <20151012212015.GO107187@google.com> (raw)
In-Reply-To: <1443808606-21203-2-git-send-email-anup.patel@broadcom.com>
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 <anup.patel@broadcom•com>
> Reviewed-by: Vikram Prakash <vikramp@broadcom•com>
> Reviewed-by: Ray Jui <rjui@broadcom•com>
> Reviewed-by: Scott Branden <sbranden@broadcom•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 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
>
next prev parent reply other threads:[~2015-10-12 21:20 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-02 17:56 [PATCH 0/5] NAND support for Broadcom NS2 SoC Anup Patel
2015-10-02 17:56 ` [PATCH 1/5] mtd: brcmnand: Fix pointer type-cast in brcmnand_write() Anup Patel
2015-10-12 21:20 ` Brian Norris [this message]
2015-10-02 17:56 ` [PATCH 2/5] mtd: nand: Allow MTD_NAND_BRCMNAND to be selected for ARM64 Anup Patel
2015-10-12 21:20 ` Brian Norris
2015-10-02 17:56 ` [PATCH 3/5] mtd: brcmnand: Optional DT flag to reset IPROC NAND controller Anup Patel
2015-10-04 21:49 ` Brian Norris
2015-10-05 6:27 ` Anup Patel
2015-10-06 13:41 ` Brian Norris
2015-10-06 22:25 ` Scott Branden
2015-10-06 23:20 ` Florian Fainelli
2015-10-07 3:33 ` Anup Patel
2015-10-12 21:27 ` Brian Norris
2015-10-16 6:46 ` Anup Patel
2015-10-12 21:54 ` Josh Cartwright
2015-10-13 17:35 ` Florian Fainelli
2015-10-02 17:56 ` [PATCH 4/5] Documentation: dt-bindings: Add info about brcm, nand-iproc-reset DT flag Anup Patel
2015-10-02 17:56 ` [PATCH 5/5] arm64: dts: Add BRCM IPROC NAND DT node for NS2 Anup Patel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151012212015.GO107187@google.com \
--to=computersforpeace@gmail$(echo .)com \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox