linux/drivers/pinctrl
Enric Balletbo i Serra db7515783b pinctrl: mediatek: Free eint data on failure
The pinctrl driver can work without the EINT resource, but, if it is
expected to have this resource but the mtk_build_eint() function fails
after allocating their data (because can't get the resource or can't map
the irq), the data is not freed and you end with a NULL pointer
dereference. Fix this by freeing the data if mtk_build_eint() fails, so
pinctrl still works and doesn't hang.

This is noticeable after commit f97dbf48ca ("irqchip/mtk-sysirq: Convert
to a platform driver") on MT8183 because, due this commit, the pinctrl driver
fails to map the irq and spots the following bug:

[    1.947597] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000004
[    1.956404] Mem abort info:
[    1.959203]   ESR = 0x96000004
[    1.962259]   EC = 0x25: DABT (current EL), IL = 32 bits
[    1.967565]   SET = 0, FnV = 0
[    1.970613]   EA = 0, S1PTW = 0
[    1.973747] Data abort info:
[    1.976619]   ISV = 0, ISS = 0x00000004
[    1.980447]   CM = 0, WnR = 0
[    1.983410] [0000000000000004] user address but active_mm is swapper
[    1.989759] Internal error: Oops: 96000004 [#1] PREEMPT SMP
[    1.995322] Modules linked in:
[    1.998371] CPU: 7 PID: 1 Comm: swapper/0 Not tainted 5.9.0-rc1+ #44
[    2.004715] Hardware name: MediaTek krane sku176 board (DT)
[    2.010280] pstate: 60000005 (nZCv daif -PAN -UAO BTYPE=--)
[    2.015850] pc : mtk_eint_set_debounce+0x48/0x1b8
[    2.020546] lr : mtk_eint_set_debounce+0x34/0x1b8
[    2.025239] sp : ffff80001008baa0
[    2.028544] x29: ffff80001008baa0 x28: ffff0000ff7ff790
[    2.033847] x27: ffff0000f9ec34b0 x26: ffff0000f9ec3480
[    2.039150] x25: ffff0000fa576410 x24: ffff0000fa502800
[    2.044453] x23: 0000000000001388 x22: ffff0000fa635f80
[    2.049755] x21: 0000000000000008 x20: 0000000000000000
[    2.055058] x19: 0000000000000071 x18: 0000000000000001
[    2.060360] x17: 0000000000000000 x16: 0000000000000000
[    2.065662] x15: ffff0000facc8470 x14: ffffffffffffffff
[    2.070965] x13: 0000000000000001 x12: 00000000000000c0
[    2.076267] x11: 0000000000000040 x10: 0000000000000070
[    2.081569] x9 : ffffaec0063d24d8 x8 : ffff0000fa800270
[    2.086872] x7 : 0000000000000000 x6 : 0000000000000011
[    2.092174] x5 : ffff0000fa800248 x4 : ffff0000fa800270
[    2.097476] x3 : ffff8000100c5000 x2 : 0000000000000000
[    2.102778] x1 : 0000000000000000 x0 : 0000000000000000
[    2.108081] Call trace:
[    2.110520]  mtk_eint_set_debounce+0x48/0x1b8
[    2.114870]  mtk_gpio_set_config+0x5c/0x78
[    2.118958]  gpiod_set_config+0x5c/0x78
[    2.122786]  gpiod_set_debounce+0x18/0x28
[    2.126789]  gpio_keys_probe+0x50c/0x910
[    2.130705]  platform_drv_probe+0x54/0xa8
[    2.134705]  really_probe+0xe4/0x3b0
[    2.138271]  driver_probe_device+0x58/0xb8
[    2.142358]  device_driver_attach+0x74/0x80
[    2.146532]  __driver_attach+0x58/0xe0
[    2.150274]  bus_for_each_dev+0x70/0xc0
[    2.154100]  driver_attach+0x24/0x30
[    2.157666]  bus_add_driver+0x14c/0x1f0
[    2.161493]  driver_register+0x64/0x120
[    2.165319]  __platform_driver_register+0x48/0x58
[    2.170017]  gpio_keys_init+0x1c/0x28
[    2.173672]  do_one_initcall+0x54/0x1b4
[    2.177499]  kernel_init_freeable+0x1d0/0x238
[    2.181848]  kernel_init+0x14/0x118
[    2.185328]  ret_from_fork+0x10/0x34
[    2.188899] Code: a9438ac1 12001266 f94006c3 121e766a (b9400421)
[    2.194991] ---[ end trace 168cf7b3324b6570 ]---
[    2.199611] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
[    2.207260] SMP: stopping secondary CPUs
[    2.211294] Kernel Offset: 0x2ebff4800000 from 0xffff800010000000
[    2.217377] PHYS_OFFSET: 0xffffb50500000000
[    2.221551] CPU features: 0x0240002,2188200c
[    2.225811] Memory Limit: none
[    2.228860] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]---

Fixes: 89132dd8ff ("pinctrl: mediatek: extend eint build to pinctrl-mtk-common-v2.c")
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Acked-by: Sean Wang <sean.wang@kernel.org>
Link: https://lore.kernel.org/r/20201001142511.3560143-1-enric.balletbo@collabora.com
[rebased on changed infrastructure]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-10-07 10:31:30 +02:00
..
actions pinctrl: actions: pinctrl-s900: Constify s900_padinfo[] 2020-09-12 12:15:19 +02:00
aspeed pinctrl: aspeed-g6: Add bias controls for 1.8V GPIO banks 2020-09-29 14:38:44 +02:00
bcm pinctrl: bcm: pinctrl-iproc-gpio: Rename incorrectly documented function param 2020-07-16 15:12:38 +02:00
berlin pinctrl: berlin: as370: fix a typo s/spififib/spdifib 2019-10-16 14:12:55 +02:00
cirrus pinctrl: madera: Add missing call to pinctrl_unregister_mappings 2020-02-29 00:34:23 +01:00
freescale pinctrl: imx: Support building i.MX pinctrl core driver as module 2020-09-29 13:44:36 +02:00
intel pinctrl: sunrisepoint: Modify COMMUNITY macros to be consistent 2020-09-30 11:43:56 +02:00
mediatek pinctrl: mediatek: Free eint data on failure 2020-10-07 10:31:30 +02:00
meson pinctrl: meson: pinctrl-meson-a1: Remove unused const variable 'i2c_slave_groups' 2020-07-16 15:58:12 +02:00
mvebu pinctrl: armada-37xx: Add comment for pcie1_reset pin group 2020-08-27 10:25:17 +02:00
nomadik pinctrl: nomadik: Fix pull direction debug info 2020-08-27 10:25:17 +02:00
nuvoton pinctrl: nuvoton: npcm7xx: Constify static ops structs 2020-09-30 10:37:52 +02:00
pxa pinctrl: pxa: pxa2xx: Remove 'pxa2xx_pinctrl_exit()' which is unused and broken 2020-06-04 00:05:13 +02:00
qcom pinctrl: qcom: Add msm8226 pinctrl driver. 2020-08-27 10:27:14 +02:00
renesas pinctrl: renesas: Reintroduce SH_PFC for common sh-pfc code 2020-09-15 10:04:35 +02:00
samsung pinctrl: samsung: Use bank name as irqchip name 2020-08-04 01:29:10 +02:00
sirf pinctrl: sirf: pinctrl-atlas7: Fix a bunch of documentation misdemeanours 2020-07-16 15:12:38 +02:00
spear pinctrl: spear: simplify the return expression of tvc_connect() 2020-09-29 15:26:25 +02:00
sprd pinctrl: sprd: use module_platform_driver to simplify the code 2020-09-29 14:53:11 +02:00
stm32 pinctrl: stm32: use the hwspin_lock_timeout_in_atomic() API 2020-07-23 15:19:28 +02:00
sunxi pinctrl: sunxi: add support for the Allwinner A100 pin controller 2020-09-12 12:35:42 +02:00
tegra This is the bulk of the pin control changes for the v5.9 2020-08-09 12:52:28 -07:00
ti pinctl: ti: iodelay: Replace HTTP links with HTTPS ones 2020-07-20 16:15:59 +02:00
uniphier pinctrl: uniphier: Replace zero-length array with flexible-array member 2020-02-21 15:36:24 +01:00
visconti pinctrl: visconti: Add Toshiba Visconti SoCs pinctrl support 2020-09-12 12:25:53 +02:00
vt8500 pinctrl: Use new GPIO_LINE_DIRECTION 2020-02-21 15:19:42 +01:00
zte pinctrl: fix several typos 2020-04-28 13:26:49 +02:00
core.c pinctrl: core: print gpio in pins debugfs file 2020-08-04 01:29:10 +02:00
core.h pinctrl: Allow modules to use pinctrl_[un]register_mappings 2019-12-30 14:27:17 +01:00
devicetree.c pinctrl: devicetree: Keep deferring even on timeout 2020-09-12 18:19:53 +02:00
devicetree.h pinctrl: devicetree.c: remove orphan pinctrl_dt_has_hogs() 2019-10-04 23:26:23 +02:00
Kconfig pinctrl: renesas: Updates for v5.10 2020-09-21 23:43:30 +02:00
Makefile pinctrl: renesas: Updates for v5.10 2020-09-21 23:43:30 +02:00
pinconf-generic.c pinctrl: pinconf-generic: Add function parameter description 'pctldev' 2020-07-16 15:12:39 +02:00
pinconf.c
pinconf.h
pinctrl-amd.c pinctrl: amd: Use irqchip template 2020-08-04 01:29:10 +02:00
pinctrl-amd.h pinctrl: amd: fix npins for uart0 in kerncz_groups 2020-06-22 09:35:39 +02:00
pinctrl-artpec6.c pinctrl: artpec6: fix __iomem on reg in set 2020-01-07 13:57:17 +01:00
pinctrl-as3722.c
pinctrl-at91-pio4.c pinctrl: at91-pio4: add support for sama7g5 SoC 2020-09-29 15:28:00 +02:00
pinctrl-at91.c pinctrl: pinctrl-at91: Demote non-kerneldoc header and complete another 2020-07-16 15:13:55 +02:00
pinctrl-at91.h
pinctrl-axp209.c pinctrl: Use new GPIO_LINE_DIRECTION 2020-02-21 15:19:42 +01:00
pinctrl-bm1880.c pinctrl: pinctrl-bm1880: Rename ill documented struct attribute entries 2020-07-16 15:13:55 +02:00
pinctrl-coh901.c pinctrl: use devm_platform_ioremap_resource() to simplify code 2019-11-05 15:33:40 +01:00
pinctrl-coh901.h
pinctrl-da850-pupd.c pinctrl: use devm_platform_ioremap_resource() to simplify code 2019-11-05 15:33:40 +01:00
pinctrl-da9062.c pinctrl: da9062: Fix error gpiolib.h path 2020-02-28 14:15:53 +01:00
pinctrl-digicolor.c pinctrl: use devm_platform_ioremap_resource() to simplify code 2019-11-05 15:33:40 +01:00
pinctrl-equilibrium.c pinctrl: Fix warning by adding missing MODULE_LICENSE 2019-11-28 09:12:43 +01:00
pinctrl-equilibrium.h pinctrl: Add pinmux & GPIO controller driver for a new SoC 2019-11-21 14:47:44 +01:00
pinctrl-falcon.c pinctrl: falcon: fix syntax error 2020-03-09 13:52:37 +01:00
pinctrl-gemini.c
pinctrl-ingenic.c pinctrl: Ingenic: Add I2S pins support for Ingenic SoCs. 2020-09-29 14:47:29 +02:00
pinctrl-lantiq.c pinctrl: fix several typos 2020-04-28 13:26:49 +02:00
pinctrl-lantiq.h
pinctrl-lpc18xx.c pinctrl: lpc18xx: Use fallthrough pseudo-keyword 2020-07-17 14:04:57 +02:00
pinctrl-max77620.c
pinctrl-mcp23s08.c pinctrl: mcp23s08: Fix mcp23x17 precious range 2020-09-12 11:31:19 +02:00
pinctrl-mcp23s08.h pinctrl: mcp23s08: Split to three parts: core, I²C, SPI 2020-04-16 14:21:23 +02:00
pinctrl-mcp23s08_i2c.c pinctrl: mcp23s08: Split to three parts: core, I²C, SPI 2020-04-16 14:21:23 +02:00
pinctrl-mcp23s08_spi.c pinctrl: mcp23s08: Split to three parts: fix ptr_ret.cocci warnings 2020-06-16 10:19:53 +02:00
pinctrl-ocelot.c pinctrl: ocelot: simplify the return expression of ocelot_gpiochip_register() 2020-09-29 15:29:24 +02:00
pinctrl-oxnas.c pinctrl: Use new GPIO_LINE_DIRECTION 2020-02-21 15:19:42 +01:00
pinctrl-palmas.c
pinctrl-pic32.c pinctrl: Use new GPIO_LINE_DIRECTION 2020-02-21 15:19:42 +01:00
pinctrl-pic32.h
pinctrl-pistachio.c pinctrl: Use new GPIO_LINE_DIRECTION 2020-02-21 15:19:42 +01:00
pinctrl-rk805.c pinctrl: rk805: Constify rk805_gpio_cfgs 2020-05-12 13:35:33 +02:00
pinctrl-rockchip.c pinctrl: rockchip: Replace HTTP links with HTTPS ones 2020-07-17 13:36:25 +02:00
pinctrl-single.c pinctrl: single: fix debug output when #pinctrl-cells = 2 2020-10-01 10:04:53 +02:00
pinctrl-st.c pinctrl: Use new GPIO_LINE_DIRECTION 2020-02-21 15:19:42 +01:00
pinctrl-stmfx.c pinctrl: stmfx: Use irqchip template 2020-08-04 01:29:10 +02:00
pinctrl-sx150x.c pinctrl: sx150x: Fix pinctrl enablement order bug 2020-09-12 18:11:09 +02:00
pinctrl-tb10x.c pinctrl: use devm_platform_ioremap_resource() to simplify code 2019-11-05 15:33:40 +01:00
pinctrl-u300.c pinctrl: use devm_platform_ioremap_resource() to simplify code 2019-11-05 15:33:40 +01:00
pinctrl-utils.c
pinctrl-utils.h
pinctrl-xway.c pinctrl: use devm_platform_ioremap_resource() to simplify code 2019-11-05 15:33:40 +01:00
pinctrl-zynq.c
pinmux.c pinctrl: pinmux: Add some missing parameter descriptions 2020-07-16 15:12:38 +02:00
pinmux.h