Linux-mtd Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: Fabio Estevam <festevam@gmail.com>
Cc: Shawn Guo <shawn.guo@linaro.org>,
	Subodh Nijsure <snijsure@grid-net.com>,
	Huang Shijie <b32955@freescale.com>,
	linux-mtd@lists.infradead.org,
	Sascha Hauer <kernel@pengutronix.de>,
	computersforpeace@gmail.com
Subject: Re: Kernel crashes when CONFIG_MTD_NAND_VERIFY_WRITE=y
Date: Fri, 10 Aug 2012 01:53:50 +0200	[thread overview]
Message-ID: <201208100153.51140.marex@denx.de> (raw)
In-Reply-To: <CAOMZO5DuG9m-SCPPxza=VFMmcWrGnp3Brry6nS8XHrCSzQqM7g@mail.gmail.com>

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@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

  reply	other threads:[~2012-08-09 23:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-09 23:43 Kernel crashes when CONFIG_MTD_NAND_VERIFY_WRITE=y Fabio Estevam
2012-08-09 23:53 ` Marek Vasut [this message]
2012-08-10  1:36   ` Fabio Estevam
2012-08-10  1:41     ` Marek Vasut
2012-08-10  1:42       ` Marek Vasut
2012-08-10  1:49       ` Fabio Estevam
2012-08-10  2:08         ` Huang Shijie
2012-08-10  2:11           ` Marek Vasut
2012-08-10  2:29           ` Fabio Estevam

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=201208100153.51140.marex@denx.de \
    --to=marex@denx.de \
    --cc=b32955@freescale.com \
    --cc=computersforpeace@gmail.com \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-mtd@lists.infradead.org \
    --cc=shawn.guo@linaro.org \
    --cc=snijsure@grid-net.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