Re: [PATCH 1/2] mtd: nand: ecc-bch: Fix the size of calc_buf/code_buf of the BCH

From: ycllin
Date: Thu Dec 10 2020 - 20:23:21 EST



Hi Miquel,
> "Miquel Raynal" <miquel.raynal@xxxxxxxxxxx>
>
> Re: [PATCH 1/2] mtd: nand: ecc-bch: Fix the size of calc_buf/code_buf of
the BCH
>
> Hi YouChing,
>
> YouChing Lin <ycllin@xxxxxxxxxxx> wrote on Thu, 10 Dec 2020 11:22:08
> +0800:
>
(deleted)
> > The root cause is that the size of calc_buf/code_buf is limited to 64
> > bytes, although sizeof(mtd->oobsize) returns 4, kzalloc() will
allocate
> > 64 bytes (cache size alignment).
> >
> > So we correct the size of calc_buf/code_buf to mtd->oobsize.
> >
> > Signed-off-by: YouChing Lin <ycllin@xxxxxxxxxxx>
> > ---
> > drivers/mtd/nand/ecc-sw-bch.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/mtd/nand/ecc-sw-bch.c
b/drivers/mtd/nand/ecc-sw-bch.c
> > index 4d8a979..0a0ac11 100644
> > --- a/drivers/mtd/nand/ecc-sw-bch.c
> > +++ b/drivers/mtd/nand/ecc-sw-bch.c
> > @@ -237,8 +237,8 @@ int nand_ecc_sw_bch_init_ctx(struct nand_device
*nand)
> >
> > engine_conf->code_size = code_size;
> > engine_conf->nsteps = nsteps;
> > - engine_conf->calc_buf = kzalloc(sizeof(mtd->oobsize), GFP_KERNEL);
> > - engine_conf->code_buf = kzalloc(sizeof(mtd->oobsize), GFP_KERNEL);
> > + engine_conf->calc_buf = kzalloc(mtd->oobsize, GFP_KERNEL);
> > + engine_conf->code_buf = kzalloc(mtd->oobsize, GFP_KERNEL);
>
> Very nice catch! If you don't mind I will merge this fix with the
> faulty commit (still in next) and I will also bring the fix to Hamming
> which will suffer from the same error.
>
> Then I will apply the second patch.

No problem, thank you for your help.


Thanks,
Youching.


CONFIDENTIALITY NOTE:

This e-mail and any attachments may contain confidential information
and/or personal data, which is protected by applicable laws. Please be
reminded that duplication, disclosure, distribution, or use of this e-mail
(and/or its attachments) or any part thereof is prohibited. If you receive
this e-mail in error, please notify us immediately and delete this mail as
well as its attachment(s) from your system. In addition, please be
informed that collection, processing, and/or use of personal data is
prohibited unless expressly permitted by personal data protection laws.
Thank you for your attention and cooperation.

Macronix International Co., Ltd.

=====================================================================



============================================================================

CONFIDENTIALITY NOTE:

This e-mail and any attachments may contain confidential information and/or personal data, which is protected by applicable laws. Please be reminded that duplication, disclosure, distribution, or use of this e-mail (and/or its attachments) or any part thereof is prohibited. If you receive this e-mail in error, please notify us immediately and delete this mail as well as its attachment(s) from your system. In addition, please be informed that collection, processing, and/or use of personal data is prohibited unless expressly permitted by personal data protection laws. Thank you for your attention and cooperation.

Macronix International Co., Ltd.

=====================================================================