linux/drivers/soc
Rasmus Villemoes ec2058ac8f soc: fsl: qe: refactor cpm_muram_alloc_common to prevent BUG on error path
If the kmalloc() fails, we try to undo the gen_pool allocation we've
just done. Unfortunately, start has already been modified to subtract
the GENPOOL_OFFSET bias, so we're freeing something that very likely
doesn't exist in the gen_pool, meaning we hit the

 kernel BUG at lib/genalloc.c:399!
 Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM
 ...
 [<803fd0e8>] (gen_pool_free) from [<80426bc8>] (cpm_muram_alloc_common+0xb0/0xc8)
 [<80426bc8>] (cpm_muram_alloc_common) from [<80426c28>] (cpm_muram_alloc+0x48/0x80)
 [<80426c28>] (cpm_muram_alloc) from [<80428214>] (ucc_slow_init+0x110/0x4f0)
 [<80428214>] (ucc_slow_init) from [<8044a718>] (qe_uart_request_port+0x3c/0x1d8)

(this was tested by just injecting a random failure by adding
"|| (get_random_int()&7) == 0" to the "if (!entry)" condition).

Refactor the code so we do the kmalloc() first, meaning that's the
thing that needs undoing in case gen_pool_alloc_algo() then
fails. This allows a later cleanup to move the locking from the
callers into the _common function, keeping the kmalloc() out of the
critical region and then, hopefully (if all the muram_alloc callers
allow) change it to a GFP_KERNEL allocation.

Reviewed-by: Timur Tabi <timur@kernel.org>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Li Yang <leoyang.li@nxp.com>
2019-12-09 13:54:36 -06:00
..
actions treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
amlogic soc: amlogic: meson-gx-socinfo: Fix S905D3 ID for VIM3L 2019-11-06 11:12:58 -08:00
aspeed soc: aspeed: Fix snoop_file_poll()'s return type 2019-12-05 10:10:08 -08:00
atmel soc: at91: Add Atmel SFR SN (Serial Number) support 2019-11-07 22:33:10 +01:00
bcm This pull request contains Broadcom ARM/ARM64/MIPS SoCs device drivers 2019-06-16 13:24:59 -07:00
dove treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
fsl soc: fsl: qe: refactor cpm_muram_alloc_common to prevent BUG on error path 2019-12-09 13:54:36 -06:00
gemini
imx ARM: SoC-related driver updates 2019-12-05 11:43:31 -08:00
ixp4xx soc: ixp4xx: Protect IXP4xx SoC drivers by ARCH_IXP4XX || COMPILE_TEST 2019-08-29 17:34:38 +02:00
lantiq treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
mediatek Merge mainline/master into arm/fixes 2019-12-05 13:18:54 -08:00
qcom drm msm + fixes for 5.5-rc1 2019-12-06 10:28:09 -08:00
renesas soc: renesas: rcar-sysc: Add R8A77961 support 2019-11-01 14:25:53 +01:00
rockchip ARM: SoC-related driver updates 2019-07-19 17:13:56 -07:00
samsung soc: samsung: exynos-asv: Potential NULL dereference in exynos_asv_update_opps() 2019-10-30 19:04:32 +01:00
sunxi treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
tegra soc/tegra: Fixes for v5.5-rc1 2019-12-06 08:28:38 -08:00
ti soc: ti: omap-prm: fix return value check in omap_prm_probe() 2019-10-29 09:57:56 -07:00
ux500 ARM: ux500: add missing of_node_put() 2019-07-23 09:49:32 +02:00
versatile treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
xilinx soc: xilinx: Set CAP_UNUSABLE requirement for versal while powering down domain 2019-10-16 12:49:41 +02:00
zte treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 194 2019-05-30 11:29:22 -07:00
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile soc: ti: fix irq-ti-sci link error 2019-07-01 15:26:09 -07:00