[U-Boot-Users] [PATCH 4/5] OneNAND support

Wolfgang Denk wd at denx.de
Sun Sep 9 01:05:38 CEST 2007


Hello,

in message <20070907010102.GA19979 at party> you wrote:
> [PATCH] OneNAND support
> 
> Signed-off-by: Kyungmin Park <kyungmin.park at samsung.com>
> ---
> diff --git a/drivers/onenand/onenand_bbt.c b/drivers/onenand/onenand_bbt.c
> new file mode 100644
> index 0000000..6a0eb57
> --- /dev/null
> +++ b/drivers/onenand/onenand_bbt.c
...
> + * check_short_pattern - [GENERIC] check if a pattern is in the buffer
> + * @param buf		the buffer to search
> + * @param len		the length of buffer to search
> + * @param paglen	the pagelength
> + * @param td		search pattern descriptor
> + *
> + * Check for a pattern at the given place. Used to search bad block
> + * tables and good / bad block identifiers. Same as check_pattern, but
> + * no optional empty check and the pattern is expected to start
> + * at offset 0.
> + */
> +static int check_short_pattern(uint8_t * buf, int len, int paglen,
> +			       struct nand_bbt_descr *td)
> +{
> +	int i;
> +	uint8_t *p = buf;
> +
> +	/* Compare the pattern */
> +	for (i = 0; i < td->len; i++) {
> +		if (p[i] != td->pattern[i])
> +			return -1;
> +	}
> +	return 0;
> +}

This should probably be replaced by a call to memmem() ?

> +/**
> + * onenand_memory_bbt - [GENERIC] create a memory based bad block table
> + * @param mtd		MTD device structure
> + * @param bd		descriptor for the good/bad block search pattern
> + *
> + * The function creates a memory based bbt by scanning the device
> + * for manufacturer / software marked good / bad blocks
> + */
> +static inline int onenand_memory_bbt(struct mtd_info *mtd,
> +				     struct nand_bbt_descr *bd)
> +{
> +	unsigned char data_buf[MAX_ONENAND_PAGESIZE];
> +
> +	bd->options &= ~NAND_BBT_SCANEMPTY;
> +	return create_bbt(mtd, data_buf, bd, -1);
> +}

This scares me. What is data_buf[] being used for? You are aware that
it goes out of scope when that function returns?


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"There is no statute of limitations on stupidity."
- Randomly produced by a computer program called Markov3.




More information about the U-Boot mailing list