[PATCH] [MTD] NAND: fix race in nand_base

Artem Bityutskiy dedekind at infradead.org
Mon Jul 23 07:22:25 EDT 2007


On Mon, 2007-07-23 at 14:17 +0300, Artem Bityutskiy wrote:
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 7e68203..3391b05 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -348,6 +348,8 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
>  	uint8_t buf[2] = { 0, 0 };
>  	int block, ret;
>  
> +	nand_get_device(chip, mtd, FL_READING);
Err, this should be FL_WRITING I guess.

> +
>  	/* Get block number */
>  	block = (int)(ofs >> chip->bbt_erase_shift);
>  	if (chip->bbt)
> @@ -370,6 +372,8 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
>  	}
>  	if (!ret)
>  		mtd->ecc_stats.badblocks++;
> +
> +	nand_release_device(mtd);
>  	return ret;
>  }

There is still the problem with nand_update_bbt() which in turn calls
mtd->read() which will deadlock. I have not found how BBT is protected.
Any suggestions/pointers?

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)




More information about the linux-mtd mailing list