linux/drivers/mtd/nand
Sheng Yong 192db1caa2 mtd: nand_bbt: set the smallest size of bbt table
When using nandsim to simulate a 128K block nand with `overridesize = 1',
the size of mtd device is too small (mtd_size = 4 * block_size) to get the
right length of bbt. Then when creating bbt, kzmalloc() will return
ZERO_SIZE_PTR. This causes a NULL pointer oops when scanning bbt.

[  952.156166] BUG: unable to handle kernel NULL pointer dereference at 0000000000000010
[  952.157064] IP: [<ffffffff8148ad4a>] nand_isreserved_bbt+0x2a/0x40
[  952.157064] PGD 0
[  952.157064] Oops: 0000 [#1] SMP
[  952.157064] Modules linked in: nandsim(+) [last unloaded: nandsim]
[  952.157064] CPU: 1 PID: 7103 Comm: modprobe Not tainted 4.2.0-rc3-next-20150724 #4
[  952.157064] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
[  952.157064] task: ffff88003e24b980 ti: ffff88003d274000 task.ti: ffff88003d274000
[  952.157064] RIP: 0010:[<ffffffff8148ad4a>]  [<ffffffff8148ad4a>] nand_isreserved_bbt+0x2a/0x40
[  952.157064] RSP: 0018:ffff88003d277b90  EFLAGS: 00010246
[  952.157064] RAX: 0000000000000010 RBX: ffff88003d5a1000 RCX: 0000000000000000
[  952.157064] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff88003d919000
[  952.157064] RBP: ffff88003d277b98 R08: 0000000000020000 R09: 0000000000000000
[  952.157064] R10: 0000000000000000 R11: 0000000000000195 R12: ffff88003d919000
[  952.157064] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
[  952.157064] FS:  00007fada4d07700(0000) GS:ffff88003fd00000(0000) knlGS:0000000000000000
[  952.157064] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[  952.157064] CR2: 0000000000000010 CR3: 0000000037924000 CR4: 00000000000006a0
[  952.157064] Stack:
[  952.157064]  ffffffff814851ec ffff88003d277ba8 ffffffff8147e35f ffff88003d277bf8
[  952.157064]  ffffffff814816f3 ffff88003d277c08 ffff88003d277bc8 0000000000000282
[  952.157064]  0000000000000001 0000000000000000 ffff88003d209540 0000000000000001
[  952.157064] Call Trace:
[  952.157064]  [<ffffffff814851ec>] ? nand_block_isreserved+0x1c/0x20
[  952.157064]  [<ffffffff8147e35f>] mtd_block_isreserved+0x1f/0x30
[  952.157064]  [<ffffffff814816f3>] allocate_partition+0x463/0x6a0
[  952.157064]  [<ffffffff81481b3b>] add_mtd_partitions+0x4b/0xe0
[  952.157064]  [<ffffffff8147f14c>] mtd_device_parse_register+0x4c/0xe0
[  952.157064]  [<ffffffffa0013daf>] ns_init_module+0xdaf/0xde4 [nandsim]
[  952.157064]  [<ffffffff8128d7c8>] ? kasprintf+0x38/0x40
[  952.157064]  [<ffffffffa0013000>] ? 0xffffffffa0013000
[  952.157064]  [<ffffffff810002c3>] do_one_initcall+0x83/0x1b0
[  952.157064]  [<ffffffff8113afab>] ? kmem_cache_alloc_trace+0x6b/0x120
[  952.157064]  [<ffffffff8160b503>] do_init_module+0x5c/0x1dd
[  952.157064]  [<ffffffff810aa4db>] load_module+0x1bbb/0x20b0
[  952.157064]  [<ffffffff810a6fc0>] ? __symbol_put+0x30/0x30
[  952.157064]  [<ffffffff810aaac9>] SyS_init_module+0xf9/0x110
[  952.157064]  [<ffffffff810aa9d1>] ? SyS_init_module+0x1/0x110
[  952.157064]  [<ffffffff81615f57>] entry_SYSCALL_64_fastpath+0x12/0x6a
[  952.157064] Code: 00 55 48 8b 87 80 01 00 00 48 89 e5 8b 88 cc 00 00 00 48 8b 80 f0 03 00 00 5d 48 d3 fe 89 f2 83 e6 03 c1 fa 02 8d 0c 36 48 63 d2 <0f> b6 04 10 d3 f8 83 e0 03 3c 02 0f 94 c0 0f b6 c0 c3 0f 1f 40
[  952.157064] RIP  [<ffffffff8148ad4a>] nand_isreserved_bbt+0x2a/0x40
[  952.157064]  RSP <ffff88003d277b90>
[  952.157064] CR2: 0000000000000010
[  952.204010] ---[ end trace 6ca2e1c041fdba36 ]---

This patch gives a smallest length to bbt, 1 byte, which is enough to
represent up to 4 blocks.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-10-11 12:58:28 -07:00
..
bcm47xxnflash mtd: nand: bcm47xxnflash: drop owner assignment from platform_drivers 2014-10-20 16:20:58 +02:00
brcmnand mtd: brcmnand: remove unnecessary fields from brcmnand_soc 2015-09-30 13:07:02 -07:00
gpmi-nand Common MTD: 2015-04-22 12:00:44 -07:00
ams-delta.c mtd: nand: ams-delta: fix overwritten mtd_info->owner in initialization 2015-01-15 19:33:03 -08:00
atmel_nand.c mtd: atmel_nand: don't map the ROM table if no pmecc table offset in DT 2015-04-05 17:47:56 -07:00
atmel_nand_ecc.h mtd: atmel_nand: add a definition for the oob reserved bytes 2015-04-05 17:47:56 -07:00
atmel_nand_nfc.h mtd: atmel_nand: check NFC busy flag by HSMC_SR instead of NFC cmd regs 2015-03-11 09:49:28 -07:00
au1550nd.c mtd: nand: drop owner assignment from platform_drivers 2014-10-20 16:20:58 +02:00
bf5xx_nand.c mtd: nand: drop owner assignment from platform_drivers 2014-10-20 16:20:58 +02:00
cafe_nand.c mtd: cafe_nand: drop duplicate .write_page implementation 2014-11-25 23:13:38 -08:00
cmx270_nand.c mtd: cmx270_nand: Remove unnecessary OOM messages 2014-01-03 11:22:29 -08:00
cs553x_nand.c mtd: cs553x_nand: Fix kasprintf() usage 2015-06-16 18:58:47 -07:00
davinci_nand.c nand: davinci: add support for 4K page size nand devices 2015-07-20 09:58:15 -07:00
denali.c mtd: nand: denali: max_banks calculation changed in revision 5.1 2015-09-29 11:44:59 -07:00
denali.h mtd: nand: denali: max_banks calculation changed in revision 5.1 2015-09-29 11:44:59 -07:00
denali_dt.c mtd: nand: drop owner assignment from platform_drivers 2014-10-20 16:20:58 +02:00
denali_pci.c mtd: denali_pci: switch to dev_err() 2015-08-18 17:21:37 -07:00
diskonchip.c arch, drivers: don't include <asm/io.h> directly, use <linux/io.h> instead 2015-08-10 23:07:05 -04:00
docg4.c mtd: nand: drop owner assignment from platform_drivers 2014-10-20 16:20:58 +02:00
fsl_elbc_nand.c mtd: fsl_elbc_nand: Fix module autoload for OF platform driver 2015-09-28 16:19:49 -07:00
fsl_ifc_nand.c mtd: fsl_ifc_nand: Fix module autoload for OF platform driver 2015-09-28 16:19:50 -07:00
fsl_upm.c mtd: nand: drop owner assignment from platform_drivers 2014-10-20 16:20:58 +02:00
fsmc_nand.c mtd: nand: fsmc: Remove BUG macros 2015-10-02 11:08:17 -07:00
gpio.c MTD updates for 3.19: 2014-12-17 09:59:26 -08:00
hisi504_nand.c genirq: Remove the deprecated 'IRQF_DISABLED' request_irq() flag entirely 2015-03-05 20:53:06 +01:00
jz4740_nand.c mtd: nand: jz4740: Convert to GPIO descriptor API 2015-02-02 01:04:36 -08:00
Kconfig mtd: nand: vf610_nfc: add hardware BCH-ECC support 2015-09-29 13:47:58 -07:00
lpc32xx_mlc.c mtd: nand: drop owner assignment from platform_drivers 2014-10-20 16:20:58 +02:00
lpc32xx_slc.c mtd: nand: lpc32xx_slc: fix calculation of timing arcs from given values 2015-10-04 22:30:49 +01:00
Makefile mtd: nand: vf610_nfc: Freescale NFC for VF610, MPC5125 and others 2015-09-29 13:47:58 -07:00
mpc5121_nfc.c mtd: mpc5121_nfc: Fix module autoload for OF platform driver 2015-09-28 16:19:51 -07:00
mxc_nand.c Merge MTD 4.3-rc updates into -next 2015-09-30 11:12:14 -07:00
nand_base.c mtd: nand: remove unused ->init_size() hook 2015-10-01 10:20:15 -07:00
nand_bbt.c mtd: nand_bbt: set the smallest size of bbt table 2015-10-11 12:58:28 -07:00
nand_bch.c
nand_ecc.c mtd: nand: add line feed to pr_err 2014-04-16 00:18:26 -07:00
nand_ids.c mtd: nand: add Toshiba TC58NVG0S3E to nand_ids table 2015-08-25 12:24:02 -07:00
nand_timings.c mtd: nand: Use ULL-suffix for big u64 constant 2014-08-19 11:53:09 -07:00
nandsim.c mtd: nandsim: drop null test before destroy functions 2015-09-21 17:04:50 -07:00
ndfc.c mtd: remove incorrect file name 2015-05-22 10:57:46 -07:00
nuc900_nand.c mtd: nand: drop owner assignment from platform_drivers 2014-10-20 16:20:58 +02:00
omap2.c mtd: nand: omap: drop condition with no effect 2015-02-05 19:51:08 -08:00
omap_elm.c mtd: omap_elm: Fix module alias 2015-08-18 17:57:46 -07:00
orion_nand.c mtd: orion_nand: Fix module autoload for OF platform driver 2015-09-28 16:19:34 -07:00
pasemi_nand.c mtd: nand: drop owner assignment from platform_drivers 2014-10-20 16:20:58 +02:00
plat_nand.c mtd: plat_nand: use default partition probe 2015-05-27 12:34:35 -07:00
pxa3xx_nand.c mtd: nand: pxa3xx-nand: prevent DFI bus lockup on removal 2015-09-28 17:32:19 -07:00
r852.c mtd: r852: make ecc_reg 32-bit in r852_ecc_correct 2015-07-20 10:38:25 -07:00
r852.h
s3c2410.c mtd: s3c2410: Constify platform_device_id 2015-05-07 00:13:24 -07:00
sh_flctl.c mtd: sh_flctl: remove slave_id settings for DMAEngine 2015-02-23 16:12:25 +05:30
sharpsl.c mtd: nand: drop owner assignment from platform_drivers 2014-10-20 16:20:58 +02:00
sm_common.c mtd: nand: refactor chip->block_markbad interface 2013-08-30 16:47:52 +01:00
sm_common.h mtd: use __packed shorthand 2014-08-19 11:53:08 -07:00
socrates_nand.c mtd: nand: drop owner assignment from platform_drivers 2014-10-20 16:20:58 +02:00
sunxi_nand.c mtd: nand: sunxi: fix bitflips in erased pages 2015-10-02 11:09:51 -07:00
tmio_nand.c mtd: tmio_nand: Use devm_*() functions 2014-01-03 11:22:28 -08:00
txx9ndfmc.c mtd: nand: drop owner assignment from platform_drivers 2014-10-20 16:20:58 +02:00
vf610_nfc.c mtd: nand: vf610_nfc: include missing pincrl/consumer.h 2015-09-30 10:21:39 -07:00
xway_nand.c mtd: plat_nand: use default partition probe 2015-05-27 12:34:35 -07:00