Kernel crashes when CONFIG_MTD_NAND_VERIFY_WRITE=y

Marek Vasut marex at denx.de
Thu Aug 9 19:53:50 EDT 2012


Dear Fabio Estevam,

> Hi,
> 
> When enabling CONFIG_MTD_NAND_VERIFY_WRITE=y on a mx28evk board
> running 3.6-rc1  I get the following crash:
> 
> root at freescale /$ dd if=/dev/zero of=/dev/mtd0 bs=128k count=1
> [   41.070000] Unable to handle kernel NULL pointer dereference at virtual
[...]

This problem is there because the GPMI NAND code doesn't implement verify buffer 
function and defaults to nand_verify_buf() call in nand_base.c:

 253 static int nand_verify_buf(struct mtd_info *mtd, const uint8_t *buf, int 
len)
 254 {
 255         int i;
 256         struct nand_chip *chip = mtd->priv;
 257 
 258         for (i = 0; i < len; i++)
 259                 if (buf[i] != readb(chip->IO_ADDR_R))
 260                         return -EFAULT;
 261         return 0;
 262 }

Now the chip->IO_ADDR_R is zero, making the kernel access bogus location, and 
therefore crash. So the correct solution is to properly implement the struct 
nand_chip *'s verify_buf function.

Best regards,
Marek Vasut



More information about the linux-mtd mailing list