From: Liang Yang <liang.yang@amlogic.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Boris Brezillon <bbrezillon@kernel.org>,
Richard Weinberger <richard@nod.at>,
kernel-janitors@vger.kernel.org,
Marek Vasut <marek.vasut@gmail.com>,
linux-mtd@lists.infradead.org,
Kevin Hilman <khilman@baylibre.com>,
Miquel Raynal <miquel.raynal@bootlin.com>,
linux-amlogic@lists.infradead.org,
Brian Norris <computersforpeace@gmail.com>,
David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH 2/3] mtd: rawnand: meson: fix a loop in meson_nand_bch_mode()
Date: Sat, 2 Feb 2019 11:01:45 +0800 [thread overview]
Message-ID: <6afa6288-cbad-9d43-002a-5f44348e9e1a@amlogic.com> (raw)
In-Reply-To: <20190201083009.GD8459@kadam>
On 2019/2/1 16:30, Dan Carpenter wrote:
> There is a sizeof() vs ARRAY_SIZE() bug here. We want the number of
> elements in the array, not the number of bytes. It means we potentially
> read beyond the end of the array.
>
> Fixes: 2d570b34b41a ("mtd: rawnand: meson: add support for Amlogic NAND flash controller")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/mtd/nand/raw/meson_nand.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c
> index 94c90be7e1e0..0d93d0b9c1af 100644
> --- a/drivers/mtd/nand/raw/meson_nand.c
> +++ b/drivers/mtd/nand/raw/meson_nand.c
> @@ -1143,7 +1143,7 @@ static int meson_nand_bch_mode(struct nand_chip *nand)
> if (nand->ecc.strength > 60 || nand->ecc.strength < 8)
> return -EINVAL;
>
> - for (i = 0; i < sizeof(meson_ecc); i++) {
> + for (i = 0; i < ARRAY_SIZE(meson_ecc); i++) {
ok.
Acked-by: Liang Yang <liang.yang@amlogic.com>
> if (meson_ecc[i].strength == nand->ecc.strength) {
> meson_chip->bch_mode = meson_ecc[i].bch;
> return 0;
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
prev parent reply other threads:[~2019-02-02 3:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-01 8:30 [PATCH 2/3] mtd: rawnand: meson: fix a loop in meson_nand_bch_mode() Dan Carpenter
2019-02-02 3:01 ` Liang Yang [this message]
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=6afa6288-cbad-9d43-002a-5f44348e9e1a@amlogic.com \
--to=liang.yang@amlogic.com \
--cc=bbrezillon@kernel.org \
--cc=computersforpeace@gmail.com \
--cc=dan.carpenter@oracle.com \
--cc=dwmw2@infradead.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=khilman@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).