OpenCloudOS-Kernel/drivers/pinctrl/sunxi
Andre Przywara d1dee81416 pinctrl: sunxi: Don't underestimate number of functions
When we are building all the various pinctrl structures for the
Allwinner pinctrl devices, we do some estimation about the maximum
number of distinct function (names) that we will need.

So far we take the number of pins as an upper bound, even though we
can actually have up to four special functions per pin. This wasn't a
problem until now, since we indeed have typically far more pins than
functions, and most pins share common functions.

However the H616 "-r" pin controller has only two pins, but four
functions, so we run over the end of the array when we are looking for
a matching function name in sunxi_pinctrl_add_function - there is no
NULL sentinel left that would terminate the loop:

[    8.200648] Unable to handle kernel paging request at virtual address fffdff7efbefaff5
[    8.209179] Mem abort info:
....
[    8.368456] Call trace:
[    8.370925]  __pi_strcmp+0x90/0xf0
[    8.374559]  sun50i_h616_r_pinctrl_probe+0x1c/0x28
[    8.379557]  platform_probe+0x68/0xd8

Do an actual worst case allocation (4 functions per pin, three common
functions and the sentinel) for the initial array allocation. This is
now heavily overestimating the number of functions in the common case,
but we will reallocate this array later with the actual number of
functions, so it's only temporarily.

Fixes: 561c1cf17c ("pinctrl: sunxi: Add support for the Allwinner H616-R pin controller")
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Acked-by: Maxime Ripard <maxime@cerno.tech>
Link: https://lore.kernel.org/r/20210722132548.22121-1-andre.przywara@arm.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2021-08-10 14:55:35 +02:00
..
Kconfig pinctrl: sunxi: Add support for the Allwinner H616-R pin controller 2021-01-21 22:15:46 +01:00
Makefile pinctrl: sunxi: Add support for the Allwinner H616-R pin controller 2021-01-21 22:15:46 +01:00
pinctrl-sun4i-a10.c pinctrl: sunxi: fix a typo when merging A20 support to A10 driver 2017-12-28 15:06:01 +01:00
pinctrl-sun5i.c pinctrl: sunxi: Disable strict mode for old pinctrl drivers 2017-10-31 09:45:00 +01:00
pinctrl-sun6i-a31-r.c pinctrl: sunxi: Disable strict mode for old pinctrl drivers 2017-10-31 09:45:00 +01:00
pinctrl-sun6i-a31.c pinctrl: sunxi: Disable strict mode for old pinctrl drivers 2017-10-31 09:45:00 +01:00
pinctrl-sun8i-a23-r.c pinctrl: sunxi: handle probe defferal 2020-04-16 10:23:02 +02:00
pinctrl-sun8i-a23.c pinctrl: sunxi: Disable strict mode for old pinctrl drivers 2017-10-31 09:45:00 +01:00
pinctrl-sun8i-a33.c pinctrl: sunxi: change irq_bank_base to irq_bank_map 2018-03-27 15:07:49 +02:00
pinctrl-sun8i-a83t-r.c pinctrl: sunxi: Add support for A83T R_PIO 2017-06-09 11:20:32 +02:00
pinctrl-sun8i-a83t.c pinctrl: sunxi: a83t: Fix IRQ offset typo for PH11 2018-12-07 13:32:19 +01:00
pinctrl-sun8i-h3-r.c pinctrl: sunxi: Disable strict mode for old pinctrl drivers 2017-10-31 09:45:00 +01:00
pinctrl-sun8i-h3.c pinctrl: sunxi: Disable strict mode for old pinctrl drivers 2017-10-31 09:45:00 +01:00
pinctrl-sun8i-v3s.c pinctrl: sunxi: v3s: introduce support for V3 2019-08-05 12:35:29 +02:00
pinctrl-sun9i-a80-r.c pinctrl: sunxi: Prepare for alternative bias voltage setting methods 2019-04-23 12:29:21 +02:00
pinctrl-sun9i-a80.c pinctrl: sunxi: Prepare for alternative bias voltage setting methods 2019-04-23 12:29:21 +02:00
pinctrl-sun50i-a64-r.c pinctrl: sunxi: Add A64 R_PIO controller support 2017-03-14 14:42:24 +01:00
pinctrl-sun50i-a64.c pinctrl: sunxi: a64: Rename function ts0 to ts 2018-12-07 13:29:28 +01:00
pinctrl-sun50i-a100-r.c pinctrl: sunxi: add support for the Allwinner A100 pin controller 2020-09-12 12:35:42 +02:00
pinctrl-sun50i-a100.c pinctrl: sunxi: fix irq bank map for the Allwinner A100 pin controller 2020-11-24 09:40:03 +01:00
pinctrl-sun50i-h5.c pinctrl: sunxi: sun50i-h5 use platform_irq_count 2020-01-07 09:55:33 +01:00
pinctrl-sun50i-h6-r.c pinctrl: sunxi: h6-r: Add s_rsb pin functions 2021-01-06 21:10:04 +01:00
pinctrl-sun50i-h6.c pinctrl: sunxi: Support I/O bias voltage setting on H6 2019-04-23 12:31:42 +02:00
pinctrl-sun50i-h616-r.c pinctrl: sunxi: Add support for the Allwinner H616-R pin controller 2021-01-21 22:15:46 +01:00
pinctrl-sun50i-h616.c pinctrl: sunxi: Add support for the Allwinner H616 pin controller 2021-01-21 22:14:18 +01:00
pinctrl-suniv-f1c100s.c pinctrl: sunxi: add support for suniv F1C100s (newer F-series SoCs) 2018-11-25 13:49:10 +01:00
pinctrl-sunxi.c pinctrl: sunxi: Don't underestimate number of functions 2021-08-10 14:55:35 +02:00
pinctrl-sunxi.h pinctrl: sunxi: v3s: introduce support for V3 2019-08-05 12:35:29 +02:00