[PATCH] pinctrl: sunxi: Don't underestimate number of functions

Linus Walleij linus.walleij at linaro.org
Tue Aug 10 05:55:58 PDT 2021


On Thu, Jul 22, 2021 at 3:26 PM Andre Przywara <andre.przywara at arm.com> wrote:

> 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: 561c1cf17c46 ("pinctrl: sunxi: Add support for the Allwinner H616-R pin controller")
> Signed-off-by: Andre Przywara <andre.przywara at arm.com>

Patch applied for fixes!
Thanks for finding this.

Yours,
Linus Walleij



More information about the linux-arm-kernel mailing list