linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: Sheng Yong <shengyong1@huawei.com>
Cc: linux-mtd@lists.infradead.org
Subject: Re: [RFC PATCH] mtd: nand_bbt: set the smallest size of bbt table
Date: Sun, 11 Oct 2015 13:01:54 -0700	[thread overview]
Message-ID: <20151011200154.GB3696@localhost> (raw)
In-Reply-To: <1438305164-82852-1-git-send-email-shengyong1@huawei.com>

On Fri, Jul 31, 2015 at 01:12:44AM +0000, Sheng Yong wrote:
> When using nandsim to simulate a 128K block nand with `overridesize = 1',
> the size of mtd device is too small (mtd_size = 4 * block_size) to get the
> right length of bbt. Then when creating bbt, kzmalloc() will return
> ZERO_SIZE_PTR. This causes a NULL pointer oops when scanning bbt.
> 
[...]
> 
> This patch gives a smallest length to bbt, 1 byte, which is enough to
> represent up to 4 blocks.
> 
> Signed-off-by: Sheng Yong <shengyong1@huawei.com>
> ---
>  drivers/mtd/nand/nand_bbt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
> index 63a1a36..b1d4f81 100644
> --- a/drivers/mtd/nand/nand_bbt.c
> +++ b/drivers/mtd/nand/nand_bbt.c
> @@ -1080,7 +1080,7 @@ static int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
>  	struct nand_bbt_descr *td = this->bbt_td;
>  	struct nand_bbt_descr *md = this->bbt_md;
>  
> -	len = mtd->size >> (this->bbt_erase_shift + 2);
> +	len = (mtd->size >> (this->bbt_erase_shift + 2)) ? : 1;
>  	/*
>  	 * Allocate memory (2bit per block) and clear the memory bad block
>  	 * table.

So that's all that needs fixed to get that small of a "NAND" working?
I'd assume something else would break too. But maybe not!

Applied to l2-mtd.git. Thanks.

      reply	other threads:[~2015-10-11 20:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-31  1:12 [RFC PATCH] mtd: nand_bbt: set the smallest size of bbt table Sheng Yong
2015-10-11 20:01 ` Brian Norris [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=20151011200154.GB3696@localhost \
    --to=computersforpeace@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=shengyong1@huawei.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 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).