[PATCH 0/3] pinctrl: bcm: Fix fsel_get() and use generic dt_free_map

From: Wang Xiaolei

Date: Fri Nov 06 2026 - 02:12:20 EST


This series contains one fix and two cleanups for the Broadcom pin
controllers.

Patch 1 fixes an off-by-one and out-of-bounds read in the STB pin
controller driver that was added in v6.18. The FSEL register field is
a 1-based function number -- 0 means GPIO, 1..n_funcs select
funcs[0..n_funcs - 1] -- but brcmstb_pinctrl_fsel_get() uses the raw
field value as a 0-based index into funcs[]. Every readback is
therefore shifted by one entry, and the value 8, which
brcmstb_pinctrl_fsel_set() accepts as the eighth alternate function,
reads funcs[8] and trips KASAN when the pin state is printed through
debugfs.

Patches 2 and 3 replace hand-written dt_free_map callbacks with
pinconf_generic_dt_free_map(). Both drivers already call
pinconf_generic_dt_node_to_map_*() for dt_node_to_map and already
select GENERIC_PINCONF, so the generic helper is the matching
counterpart, and the open-coded free loop just duplicates what
pinctrl_utils_free_map() already does. No functional change is
intended for the map types the existing device trees use.

Patch 1 was tested on a Raspberry Pi 5 with KASAN enabled. Before the
change, writing "gpio45 alt8" to pinmux-select and then reading pins
triggers a global-out-of-bounds splat in brcmstb_pctl_pin_dbg_show();
after the change the same sequence reports "function spi_m" without
a warning, and a register field value of 0 reports "gpio".

The series is based on v7.4-rc1 and has no inter-patch dependencies.


Wang Xiaolei (3):
pinctrl: bcm: Fix off-by-one and out-of-bounds access in fsel_get()
pinctrl: bcm: Use pinconf_generic_dt_free_map in bcm2835
pinctrl: bcm: Use pinconf_generic_dt_free_map in brcmstb

drivers/pinctrl/bcm/pinctrl-bcm2835.c | 16 ++--------------
drivers/pinctrl/bcm/pinctrl-brcmstb.c | 26 +++++++++++---------------
2 files changed, 13 insertions(+), 29 deletions(-)

--
2.34.1