[PATCH 1/1] mtd: nand: add check for out of page read
Artem Bityutskiy
dedekind1 at gmail.com
Sun Dec 19 11:54:05 EST 2010
On Wed, 2010-12-15 at 09:55 +0800, Jason Liu wrote:
> > /* Do not allow reads past end of device */
> > if (unlikely(from >= mtd->size ||
> > ops->ooboffs + readlen > ((mtd->size >> chip->page_shift) -
> > (from >> chip->page_shift)) * len)) {
> > DEBUG(MTD_DEBUG_LEVEL0, "%s: Attempt read beyond end "
> > "of device\n", __func__);
> > return -EINVAL;
> > }
>
> Here the mtd->size in nand_base.c should be the NAND flash chip size,
I think this is partition size as well.
> while in nand_oobtest,
>
> /* Attempt to read off end of device */
> ops.mode = MTD_OOB_AUTO;
> ops.len = 0;
> ops.retlen = 0;
> ops.ooblen = mtd->ecclayout->oobavail;
> ops.oobretlen = 0;
> ops.ooboffs = 1;
> ops.datbuf = NULL;
> ops.oobbuf = readbuf;
> printk(PRINT_PREF "attempting to read past end of device\n");
> printk(PRINT_PREF "an error is expected...\n");
> err = mtd->read_oob(mtd, mtd->size - mtd->writesize, &ops);
> if (err) {
> printk(PRINT_PREF "error occurred as expected\n");
> err = 0;
> } else {
> printk(PRINT_PREF "error: read past end of device\n");
> errcnt += 1;
> }
> }
>
> here, mtd->size is mtd partition size right? when the mtd partition is
> not the last MTD partition, the error will happen.
I think this is the same in both. Try to debug this with printks().
>
> I have tested on real NAND, while not on nandsim.
Please, try to reproduce this with nandsim as well, and if it works, try
to find out why (using printk debugging)
--
Best Regards,
Artem Bityutskiy (Битюцкий Артём)
More information about the linux-mtd
mailing list