diff options
author | Huang Shijie <b32955@freescale.com> | 2013-11-11 23:23:08 -0500 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2013-11-12 13:17:57 -0500 |
commit | 885d71e5838f68d5dbee92ab952cc90ad6c1dc6b (patch) | |
tree | 00ca6033b20af7e0b6f4fd52fb155d6060dcf2af /drivers/mtd/nand | |
parent | 7b3d2fb92067bcb29f0f085a9fa9fa64920a6646 (diff) |
mtd: gpmi: fix the NULL pointer
The imx23 board will check the fingerprint, so it will call the
mx23_check_transcription_stamp. This function will use @chip->buffers->databuf
as its buffer which is allocated in the nand_scan_tail().
Unfortunately, the mx23_check_transcription_stamp is called before the
nand_scan_tail(). So we will meet a NULL pointer bug:
--------------------------------------------------------------------
[ 1.150000] NAND device: Manufacturer ID: 0xec, Chip ID: 0xd7 (Samsung NAND 4GiB 3,3V 8-bit), 4096MiB, page size: 4096, OOB size: 8
[ 1.160000] Unable to handle kernel NULL pointer dereference at virtual address 000005d0
[ 1.170000] pgd = c0004000
[ 1.170000] [000005d0] *pgd=00000000
[ 1.180000] Internal error: Oops: 5 [#1] ARM
[ 1.180000] Modules linked in:
[ 1.180000] CPU: 0 PID: 1 Comm: swapper Not tainted 3.12.0 #89
[ 1.180000] task: c7440000 ti: c743a000 task.ti: c743a000
[ 1.180000] PC is at memcmp+0x10/0x54
[ 1.180000] LR is at gpmi_nand_probe+0x42c/0x894
[ 1.180000] pc : [<c025fcb0>] lr : [<c02f6a68>] psr: 20000053
[ 1.180000] sp : c743be2c ip : 600000d3 fp : ffffffff
[ 1.180000] r10: 000005d0 r9 : c02f5f08 r8 : 00000000
[ 1.180000] r7 : c75858a8 r6 : c75858a8 r5 : c7585b18 r4 : c7585800
[ 1.180000] r3 : 000005d0 r2 : 00000004 r1 : c05c33e4 r0 : 000005d0
[ 1.180000] Flags: nzCv IRQs on FIQs off Mode SVC_32 ISA ARM Segment kernel
[ 1.180000] Control: 0005317f Table: 40004000 DAC: 00000017
[ 1.180000] Process swapper (pid: 1, stack limit = 0xc743a1c0)
--------------------------------------------------------------------
This patch rearrange the init procedure:
Set the NAND_SKIP_BBTSCAN to skip the nand scan firstly, and after we
set the proper settings, we will call the chip->scan_bbt() manually.
Cc: stable@vger.kernel.org # 3.12
Signed-off-by: Huang Shijie <b32955@freescale.com>
Reported-by: Fabio Estevam <festevam@gmail.com>
Tested-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r-- | drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c index c7243dca90fd..dabbc14db563 100644 --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c | |||
@@ -1578,8 +1578,6 @@ static int gpmi_set_geometry(struct gpmi_nand_data *this) | |||
1578 | 1578 | ||
1579 | static int gpmi_pre_bbt_scan(struct gpmi_nand_data *this) | 1579 | static int gpmi_pre_bbt_scan(struct gpmi_nand_data *this) |
1580 | { | 1580 | { |
1581 | int ret; | ||
1582 | |||
1583 | /* Set up swap_block_mark, must be set before the gpmi_set_geometry() */ | 1581 | /* Set up swap_block_mark, must be set before the gpmi_set_geometry() */ |
1584 | if (GPMI_IS_MX23(this)) | 1582 | if (GPMI_IS_MX23(this)) |
1585 | this->swap_block_mark = false; | 1583 | this->swap_block_mark = false; |
@@ -1587,12 +1585,8 @@ static int gpmi_pre_bbt_scan(struct gpmi_nand_data *this) | |||
1587 | this->swap_block_mark = true; | 1585 | this->swap_block_mark = true; |
1588 | 1586 | ||
1589 | /* Set up the medium geometry */ | 1587 | /* Set up the medium geometry */ |
1590 | ret = gpmi_set_geometry(this); | 1588 | return gpmi_set_geometry(this); |
1591 | if (ret) | ||
1592 | return ret; | ||
1593 | 1589 | ||
1594 | /* NAND boot init, depends on the gpmi_set_geometry(). */ | ||
1595 | return nand_boot_init(this); | ||
1596 | } | 1590 | } |
1597 | 1591 | ||
1598 | static void gpmi_nfc_exit(struct gpmi_nand_data *this) | 1592 | static void gpmi_nfc_exit(struct gpmi_nand_data *this) |
@@ -1682,10 +1676,16 @@ static int gpmi_nfc_init(struct gpmi_nand_data *this) | |||
1682 | if (ret) | 1676 | if (ret) |
1683 | goto err_out; | 1677 | goto err_out; |
1684 | 1678 | ||
1679 | chip->options |= NAND_SKIP_BBTSCAN; | ||
1685 | ret = nand_scan_tail(mtd); | 1680 | ret = nand_scan_tail(mtd); |
1686 | if (ret) | 1681 | if (ret) |
1687 | goto err_out; | 1682 | goto err_out; |
1688 | 1683 | ||
1684 | ret = nand_boot_init(this); | ||
1685 | if (ret) | ||
1686 | goto err_out; | ||
1687 | chip->scan_bbt(mtd); | ||
1688 | |||
1689 | ppdata.of_node = this->pdev->dev.of_node; | 1689 | ppdata.of_node = this->pdev->dev.of_node; |
1690 | ret = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0); | 1690 | ret = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0); |
1691 | if (ret) | 1691 | if (ret) |