mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] pinctrl: bcm: Fix fsel_get() and use generic dt_free_map
@ 2026-11-06  7:06 Wang Xiaolei
  2026-11-06  7:06 ` [PATCH 1/3] pinctrl: bcm: Fix off-by-one and out-of-bounds access in fsel_get() Wang Xiaolei
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Wang Xiaolei @ 2026-11-06  7:06 UTC (permalink / raw)
  To: linusw, florian.fainelli, rjui, sbranden,
	bcm-kernel-feedback-list, daniel, wangxiaolei01, iivanov,
	andrea.porta, phil
  Cc: linux-gpio, linux-rpi-kernel, linux-arm-kernel, linux-kernel

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-11-10 17:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-06  7:06 [PATCH 0/3] pinctrl: bcm: Fix fsel_get() and use generic dt_free_map Wang Xiaolei
2026-11-06  7:06 ` [PATCH 1/3] pinctrl: bcm: Fix off-by-one and out-of-bounds access in fsel_get() Wang Xiaolei
2026-11-10 17:46   ` Florian Fainelli
2026-11-06  7:06 ` [PATCH 2/3] pinctrl: bcm: Use pinconf_generic_dt_free_map in bcm2835 Wang Xiaolei
2026-11-10 17:48   ` Florian Fainelli
2026-11-06  7:06 ` [PATCH 3/3] pinctrl: bcm: Use pinconf_generic_dt_free_map in brcmstb Wang Xiaolei
2026-11-10 17:49   ` Florian Fainelli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®