Message ID | 1461695776-29740-1-git-send-email-zajec5@gmail.com |
---|---|
State | Superseded |
Headers | show |
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).
On 26 April 2016 at 20:53, Boris Brezillon <boris.brezillon@free-electrons.com> wrote: > 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? Sure, if you think it's better. I'll send V2.
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; if (!strcasecmp(pm, nand_ecc_algos[i])) return i; return -ENODEV;
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(+)