mirror of https://github.com/hak5/openwrt.git
kernel: generic: 5.4: fix mtd concat panic on read/write functions
Commit 2431c4f5b46c32c4ac495456b1ef4ce59c0bb85d ("mtd: Implement mtd_{read,write}() as wrappers around mtd_{read,write}_oob()") for kernel 5.4 restrict mtd devices to register only one type of read/write functions (either generic or OOB). mtd concat does not follow above rule and defines both methods at the same time, causing this type of device to be rejected by kernel. For routers that use mtd concat for root UBI volume that means kernel panic and boot loop with following error: [ 0.767307] Creating 1 MTD partitions on "ubi-concat": [ 0.772547] 0x000000000000-0x000007500000 : "ubi" [ 0.777953] ------------[ cut here ]------------ [ 0.782683] WARNING: CPU: 0 PID: 1 at drivers/mtd/mtdcore.c:621 add_mtd_device+0x84/0x5f4 [ 0.790983] Modules linked in: [ 0.794093] CPU: 0 PID: 1 Comm: swapper Not tainted 5.4.24 #0 [ 0.799932] Stack : 80680000 8062af20 00000000 00000000 8062a0f0 87c2dae4 87c282fc 8065fd23 [ 0.808430] 805c64f4 00000001 807b32d8 80670000 80670000 00000001 87c2da98 25c15bcb [ 0.816909] 00000000 00000000 807e0000 0000006e 61696e74 00000000 2e342e32 34202330 [ 0.825397] 0000006e cef2ada7 00000000 000c1ded 00000000 00000009 00000000 8034de64 [ 0.833889] 00000009 80670000 80670000 80676d18 00000000 80320044 00000000 807b0000 [ 0.842381] ... [ 0.844861] Call Trace: [ 0.847367] [<80069994>] show_stack+0x30/0x100 [ 0.851913] [<8007e8ac>] __warn+0xc0/0x10c [ 0.856072] [<8007e954>] warn_slowpath_fmt+0x5c/0xac [ 0.861134] [<8034de64>] add_mtd_device+0x84/0x5f4 [ 0.866001] [<80352a50>] add_mtd_partitions+0xd8/0x1b8 [ 0.871231] [<803527b8>] parse_mtd_partitions+0x238/0x3f8 [ 0.876717] [<8034e51c>] mtd_device_parse_register+0x48/0x1b0 [ 0.882586] [<8038dd2c>] virt_concat_probe+0x170/0x1ec [ 0.887820] [<803334c8>] platform_drv_probe+0x40/0x94 [ 0.892970] [<80331638>] really_probe+0x104/0x35c [ 0.897766] [<80331d54>] device_driver_attach+0x70/0x98 [ 0.903072] [<80331ddc>] __driver_attach+0x60/0x100 [ 0.908042] [<8032f668>] bus_for_each_dev+0x68/0xa4 [ 0.912989] [<803309d4>] bus_add_driver+0x1f0/0x200 [ 0.917952] [<80332448>] driver_register+0x84/0x148 [ 0.922906] [<80060a1c>] do_one_initcall+0x7c/0x1dc [ 0.927870] [<80684e14>] kernel_init_freeable+0x158/0x23c [ 0.933361] [<805387d8>] kernel_init+0x10/0xf0 [ 0.937883] [<80064dd8>] ret_from_kernel_thread+0x14/0x1c [ 0.943375] ---[ end trace 62e0927fba490f68 ]--- [...] [ 2.266513] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) [ 2.274893] Rebooting in 1 seconds.. This patch makes mtd concat to follow new mtd requirements by registering either normal or oob versions of read/write functions, but not both at the same time. OOB is used only when underlying mtd devices provide such functionality (like NAND chips) - otherwise generic methods are used. Tested successfully on Netgear WNDR4300. Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>master
parent
521ab1b97b
commit
e2b89ea069
|
@ -0,0 +1,24 @@
|
||||||
|
--- a/drivers/mtd/mtdconcat.c
|
||||||
|
+++ b/drivers/mtd/mtdconcat.c
|
||||||
|
@@ -642,8 +642,12 @@ struct mtd_info *mtd_concat_create(struc
|
||||||
|
concat->mtd._writev = concat_writev;
|
||||||
|
if (subdev[0]->_read_oob)
|
||||||
|
concat->mtd._read_oob = concat_read_oob;
|
||||||
|
+ else
|
||||||
|
+ concat->mtd._read = concat_read;
|
||||||
|
if (subdev[0]->_write_oob)
|
||||||
|
concat->mtd._write_oob = concat_write_oob;
|
||||||
|
+ else
|
||||||
|
+ concat->mtd._write = concat_write;
|
||||||
|
if (subdev[0]->_block_isbad)
|
||||||
|
concat->mtd._block_isbad = concat_block_isbad;
|
||||||
|
if (subdev[0]->_block_markbad)
|
||||||
|
@@ -701,8 +705,6 @@ struct mtd_info *mtd_concat_create(struc
|
||||||
|
concat->mtd.name = name;
|
||||||
|
|
||||||
|
concat->mtd._erase = concat_erase;
|
||||||
|
- concat->mtd._read = concat_read;
|
||||||
|
- concat->mtd._write = concat_write;
|
||||||
|
concat->mtd._sync = concat_sync;
|
||||||
|
concat->mtd._lock = concat_lock;
|
||||||
|
concat->mtd._unlock = concat_unlock;
|
Loading…
Reference in New Issue