All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: "Rafał Miłecki" <zajec5@gmail.com>
Cc: linux-mtd@lists.infradead.org,
	Richard Weinberger <richard@nod.at>,
	David Woodhouse <dwmw2@infradead.org>,
	Brian Norris <computersforpeace@gmail.com>,
	linux-kernel@vger.kernel.org (open list)
Subject: Re: [PATCH] mtd: nand: fix NULL pointer dereference in of_get_nand_ecc_algo
Date: Tue, 26 Apr 2016 20:53:44 +0200	[thread overview]
Message-ID: <20160426205344.17ab81cb@bbrezillon> (raw)
In-Reply-To: <1461695776-29740-1-git-send-email-zajec5@gmail.com>

On Tue, 26 Apr 2016 20:36:16 +0200
Rafał Miłecki <zajec5@gmail.com> wrote:

> Our array nand_ecc_algos doesn't specify mappings for all available
> enum nand_ecc_algo values. The one missing there is NAND_ECC_UNKNOWN
> as this value is reserved for algorithm not being specified at all.
> It means we have to be careful when iterating this array and handle
> NULL values.
> 
> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
> ---
> Hi Boris,
> 
> Sorry for this crash in nand subsystem :( If you think it's OK you may
> pick this patch as a fixup for
> c6e002a7ca9f ("mtd: nand: add support for "nand-ecc-algo" DT property")
> ---
>  drivers/mtd/nand/nand_base.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index a5417a0..0eaa9dc 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -4016,6 +4016,8 @@ static int of_get_nand_ecc_algo(struct device_node *np)
>  	err = of_property_read_string(np, "nand-ecc-algo", &pm);
>  	if (!err) {
>  		for (i = 0; i < ARRAY_SIZE(nand_ecc_algos); i++)
> +			if (!nand_ecc_algos[i])
> +				continue;

Can we add an "unknown" entry, or start iterating at NAND_ECC_HAMMING
or NAND_ECC_UNKNOWN + 1 instead of adding this extra test?

BTW, since the original commit has been applied recently I'll squash the
changes into the previous commit and rebase my branch instead of adding
a new patch (I hate breaking bisectability).


-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

  reply	other threads:[~2016-04-26 18:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-26 18:36 [PATCH] mtd: nand: fix NULL pointer dereference in of_get_nand_ecc_algo Rafał Miłecki
2016-04-26 18:53 ` Boris Brezillon [this message]
2016-04-26 19:57   ` Rafał Miłecki
2016-04-26 21:16 ` [PATCH V2] " Rafał Miłecki
2016-04-27  7:54   ` Boris Brezillon

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=20160426205344.17ab81cb@bbrezillon \
    --to=boris.brezillon@free-electrons.com \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=zajec5@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.