[RFC PATCH] mtd: nand_bbt: set the smallest size of bbt table

Brian Norris computersforpeace at gmail.com
Sun Oct 11 13:01:54 PDT 2015


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 at 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.



More information about the linux-mtd mailing list