[PATCH 09/10] pinctrl: sunplus: Validate pin_func index in sppctl_dt_node_to_map()
From: Lee Jones
Date: Wed Nov 11 2026 - 16:56:14 EST
In sppctl_dt_node_to_map(), the validation loop checks that pin_num is
within sppctl_pins_all_sz, but does not validate pin_func (bits 15:8)
before indexing sppctl_list_funcs[pin_func] for fully-pinmuxed pins.
Check that pin_func is less than sppctl_list_funcs_sz when pin_type
selects a mux function.
Fixes: aa74c44be19c ("pinctrl: Add driver for Sunplus SP7021")
Closes: https://sashiko.dev/#/bug/linux-977252d6-b0cc-4d3a-ae2d-59d1e2f8a649
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/pinctrl/sunplus/sppctl.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/sunplus/sppctl.c b/drivers/pinctrl/sunplus/sppctl.c
index 8a3fb9b56597..843641528e4e 100644
--- a/drivers/pinctrl/sunplus/sppctl.c
+++ b/drivers/pinctrl/sunplus/sppctl.c
@@ -867,8 +867,13 @@ static int sppctl_dt_node_to_map(struct pinctrl_dev *pctldev, struct device_node
for (i = 0; i < (*num_maps); i++) {
dt_pin = be32_to_cpu(list[i]);
pin_num = FIELD_GET(GENMASK(31, 24), dt_pin);
+ pin_type = FIELD_GET(GENMASK(23, 16), dt_pin);
+ pin_func = FIELD_GET(GENMASK(15, 8), dt_pin);
- if (pin_num >= sppctl_pins_all_sz) {
+ if (pin_num >= sppctl_pins_all_sz ||
+ (pin_type != SPPCTL_PCTL_G_GPIO &&
+ pin_type != SPPCTL_PCTL_G_IOPP &&
+ pin_func >= sppctl_list_funcs_sz)) {
dev_err(pctldev->dev, "Invalid pin property at index %d (0x%08x)\n",
i, dt_pin);
return -EINVAL;
--
2.56.0.567.gdb80ae8cd5-goog