* [PATCH 00/10] pinctrl: Fix resource leaks, out-of-bounds accesses, and error handling (batch 2)
@ 2026-11-11 21:51 Lee Jones
2026-11-11 21:51 ` [PATCH 01/10] pinctrl: nuvoton: ma35: Unmap reg_base and release clock on probe error Lee Jones
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: Lee Jones @ 2026-11-11 21:51 UTC (permalink / raw)
To: lee
Cc: linux-kernel, Andreas Färber, Andrew Jeffery,
Andy Shevchenko, Avi Fishman, Benjamin Fair, Dvorkin Dmitry,
Haojian Zhuang, Harshit Mogalapalli, Jacky Huang, James Tai,
jordan_hargrave, Linus Walleij, linux-arm-kernel, linux-gpio,
linux-omap, linux-realtek-soc, Nancy Yuen, openbmc,
Patrick Venture, Shan-Chun Hung, Tali Perry, tomer.maimon,
Tomer Maimon, Tony Lindgren, Tzuyi Chang, Wells Lu, Yu-Chun Lin
These issues were reported by Sashiko (batch 2).
Cc: "Andreas Färber" <afaerber@suse.com>
Cc: Andrew Jeffery <andrew@codeconstruct.com.au>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Avi Fishman <avifishman70@gmail.com>
Cc: Benjamin Fair <benjaminfair@google.com>
Cc: Dvorkin Dmitry <dvorkin@tibbo.com>
Cc: Haojian Zhuang <haojian.zhuang@linaro.org>
Cc: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Cc: Jacky Huang <ychuang3@nuvoton.com>
Cc: James Tai <james.tai@realtek.com>
Cc: jordan_hargrave@dell.com
Cc: Linus Walleij <linusw@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-gpio@vger.kernel.org
Cc: linux-omap@vger.kernel.org
Cc: linux-realtek-soc@lists.infradead.org
Cc: Nancy Yuen <yuenn@google.com>
Cc: openbmc@lists.ozlabs.org
Cc: Patrick Venture <venture@google.com>
Cc: Shan-Chun Hung <schung@nuvoton.com>
Cc: Tali Perry <tali.perry1@gmail.com>
Cc: tomer.maimon@nuvoton.com
Cc: Tomer Maimon <tmaimon77@gmail.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Tzuyi Chang <tychang@realtek.com>
Cc: Wells Lu <wellslutw@gmail.com>
Cc: Yu-Chun Lin <eleanor.lin@realtek.com>
Lee Jones (10):
pinctrl: nuvoton: ma35: Unmap reg_base and release clock on probe
error
pinctrl: nuvoton: ma35: Prevent out-of-bounds write in
ma35_pinctrl_get_soc_data()
pinctrl: nuvoton: ma35: Assign fwnode to gpio_chip in
ma35_gpiolib_register()
pinctrl: nuvoton: ma35: Avoid leaking map when parent node is missing
pinctrl: nuvoton: npcm8xx: Propagate npcm8xx_gpio_register() error in
probe
pinctrl: nuvoton: npcm7xx: Fix fwnode_irq_get() error check in
npcm7xx_gpio_of()
pinctrl: single: Reject invalid register width in pcs_probe()
pinctrl: single: Free pinconf settings array in pcs_dt_free_map()
pinctrl: sunplus: Validate pin_func index in sppctl_dt_node_to_map()
pinctrl: realtek: rtd1625: Set dcycle_offset to NA for pins without
duty-cycle support
drivers/pinctrl/nuvoton/pinctrl-ma35.c | 55 ++++++++++++++++++-----
drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c | 7 +--
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c | 2 +-
drivers/pinctrl/pinctrl-single.c | 42 +++++++++--------
drivers/pinctrl/realtek/pinctrl-rtd1625.c | 12 ++---
drivers/pinctrl/sunplus/sppctl.c | 7 ++-
6 files changed, 85 insertions(+), 40 deletions(-)
--
2.56.0.567.gdb80ae8cd5-goog
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 01/10] pinctrl: nuvoton: ma35: Unmap reg_base and release clock on probe error
2026-11-11 21:51 [PATCH 00/10] pinctrl: Fix resource leaks, out-of-bounds accesses, and error handling (batch 2) Lee Jones
@ 2026-11-11 21:51 ` Lee Jones
2026-11-11 21:51 ` [PATCH 02/10] pinctrl: nuvoton: ma35: Prevent out-of-bounds write in ma35_pinctrl_get_soc_data() Lee Jones
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Lee Jones @ 2026-11-11 21:51 UTC (permalink / raw)
To: lee, Jacky Huang, Shan-Chun Hung, Linus Walleij,
linux-arm-kernel, linux-gpio, linux-kernel
Cc: stable
ma35_get_bank_data() maps bank->reg_base via fwnode_iomap() and acquires
and enables bank->clk via of_clk_get() and clk_prepare_enable(), neither
of which is devres-managed. If of_clk_get() or clk_prepare_enable()
fails, bank->reg_base is leaked, and ma35_pinctrl_get_soc_data() ignores
the error and continues probing with an uninitialised bank.
Register devm cleanup actions for bank->reg_base and bank->clk, and
propagate errors from ma35_get_bank_data() in ma35_pinctrl_get_soc_data().
Fixes: f805e356313b ("pinctrl: nuvoton: Add ma35d1 pinctrl and GPIO driver")
Closes: https://sashiko.dev/#/bug/linux-2046e6c6-45d1-42d4-ae9f-27fac33b07e7
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/pinctrl/nuvoton/pinctrl-ma35.c | 36 ++++++++++++++++++++++----
1 file changed, 31 insertions(+), 5 deletions(-)
diff --git a/drivers/pinctrl/nuvoton/pinctrl-ma35.c b/drivers/pinctrl/nuvoton/pinctrl-ma35.c
index a79ebf4be2c3..408927ab19da 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-ma35.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-ma35.c
@@ -555,6 +555,22 @@ static int ma35_gpiolib_register(struct platform_device *pdev, struct ma35_pinct
return 0;
}
+static void ma35_bank_iounmap(void *data)
+{
+ struct ma35_pin_bank *bank = data;
+
+ iounmap(bank->reg_base);
+ bank->reg_base = NULL;
+}
+
+static void ma35_bank_clk_release(void *data)
+{
+ struct ma35_pin_bank *bank = data;
+
+ clk_disable_unprepare(bank->clk);
+ clk_put(bank->clk);
+}
+
static int ma35_get_bank_data(struct ma35_pin_bank *bank)
{
int ret;
@@ -563,6 +579,10 @@ static int ma35_get_bank_data(struct ma35_pin_bank *bank)
if (!bank->reg_base)
return -ENOMEM;
+ ret = devm_add_action_or_reset(bank->dev, ma35_bank_iounmap, bank);
+ if (ret)
+ return ret;
+
bank->irq = fwnode_irq_get(bank->fwnode, 0);
bank->nr_pins = MA35_GPIO_PORT_MAX;
@@ -572,10 +592,12 @@ static int ma35_get_bank_data(struct ma35_pin_bank *bank)
return PTR_ERR(bank->clk);
ret = clk_prepare_enable(bank->clk);
- if (ret)
+ if (ret) {
clk_put(bank->clk);
+ return ret;
+ }
- return ret;
+ return devm_add_action_or_reset(bank->dev, ma35_bank_clk_release, bank);
}
static int ma35_pinctrl_get_soc_data(struct ma35_pinctrl *pctl, struct platform_device *pdev)
@@ -583,7 +605,7 @@ static int ma35_pinctrl_get_soc_data(struct ma35_pinctrl *pctl, struct platform_
struct fwnode_handle *child;
struct ma35_pin_ctrl *ctrl;
struct ma35_pin_bank *bank;
- int i, id = 0;
+ int i, id = 0, ret;
ctrl = pctl->ctrl;
ctrl->nr_banks = MA35_GPIO_BANK_MAX;
@@ -603,8 +625,12 @@ static int ma35_pinctrl_get_soc_data(struct ma35_pinctrl *pctl, struct platform_
bank->fwnode = child;
bank->regmap = pctl->regmap;
bank->dev = &pdev->dev;
- if (!ma35_get_bank_data(bank))
- bank->valid = true;
+ ret = ma35_get_bank_data(bank);
+ if (ret) {
+ fwnode_handle_put(child);
+ return ret;
+ }
+ bank->valid = true;
id++;
}
return 0;
--
2.56.0.567.gdb80ae8cd5-goog
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 02/10] pinctrl: nuvoton: ma35: Prevent out-of-bounds write in ma35_pinctrl_get_soc_data()
2026-11-11 21:51 [PATCH 00/10] pinctrl: Fix resource leaks, out-of-bounds accesses, and error handling (batch 2) Lee Jones
2026-11-11 21:51 ` [PATCH 01/10] pinctrl: nuvoton: ma35: Unmap reg_base and release clock on probe error Lee Jones
@ 2026-11-11 21:51 ` Lee Jones
2026-11-11 21:51 ` [PATCH 03/10] pinctrl: nuvoton: ma35: Assign fwnode to gpio_chip in ma35_gpiolib_register() Lee Jones
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Lee Jones @ 2026-11-11 21:51 UTC (permalink / raw)
To: lee, Jacky Huang, Shan-Chun Hung, Linus Walleij,
linux-arm-kernel, linux-gpio, linux-kernel
Cc: stable
ma35_pinctrl_get_soc_data() allocates ctrl->pin_banks with
ctrl->nr_banks (MA35_GPIO_BANK_MAX) entries and populates them while
iterating over child GPIO controller nodes with
for_each_gpiochip_node(). If the Device Tree contains more than
MA35_GPIO_BANK_MAX GPIO controller child nodes, id exceeds
ctrl->nr_banks and writes past the end of ctrl->pin_banks.
Check that id is within ctrl->nr_banks before indexing ctrl->pin_banks.
Fixes: f805e356313b ("pinctrl: nuvoton: Add ma35d1 pinctrl and GPIO driver")
Closes: https://sashiko.dev/#/bug/linux-7f04e7c5-6691-4586-b0f9-392f1285514c
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/pinctrl/nuvoton/pinctrl-ma35.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/pinctrl/nuvoton/pinctrl-ma35.c b/drivers/pinctrl/nuvoton/pinctrl-ma35.c
index 408927ab19da..04528e734bc9 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-ma35.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-ma35.c
@@ -621,6 +621,12 @@ static int ma35_pinctrl_get_soc_data(struct ma35_pinctrl *pctl, struct platform_
}
for_each_gpiochip_node(&pdev->dev, child) {
+ if (id >= ctrl->nr_banks) {
+ dev_err(&pdev->dev, "Exceeded max GPIO banks (%u)\n",
+ ctrl->nr_banks);
+ fwnode_handle_put(child);
+ return -EINVAL;
+ }
bank = &ctrl->pin_banks[id];
bank->fwnode = child;
bank->regmap = pctl->regmap;
--
2.56.0.567.gdb80ae8cd5-goog
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 03/10] pinctrl: nuvoton: ma35: Assign fwnode to gpio_chip in ma35_gpiolib_register()
2026-11-11 21:51 [PATCH 00/10] pinctrl: Fix resource leaks, out-of-bounds accesses, and error handling (batch 2) Lee Jones
2026-11-11 21:51 ` [PATCH 01/10] pinctrl: nuvoton: ma35: Unmap reg_base and release clock on probe error Lee Jones
2026-11-11 21:51 ` [PATCH 02/10] pinctrl: nuvoton: ma35: Prevent out-of-bounds write in ma35_pinctrl_get_soc_data() Lee Jones
@ 2026-11-11 21:51 ` Lee Jones
2026-11-11 21:51 ` [PATCH 04/10] pinctrl: nuvoton: ma35: Avoid leaking map when parent node is missing Lee Jones
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Lee Jones @ 2026-11-11 21:51 UTC (permalink / raw)
To: lee, Jacky Huang, Shan-Chun Hung, Linus Walleij,
linux-arm-kernel, linux-gpio, linux-kernel
Cc: stable
ma35_gpiolib_register() registers all 14 GPIO banks under the same
parent platform device without setting bank->chip.fwnode to the child
bank node. Consequently, all GPIO banks share the parent pinctrl node
for OF/fwnode lookups, preventing consumer drivers from resolving
phandles to individual GPIO bank child nodes (&gpiob, &gpioc, etc.).
Set bank->chip.fwnode to bank->fwnode before registering each GPIO
chip.
Fixes: f805e356313b ("pinctrl: nuvoton: Add ma35d1 pinctrl and GPIO driver")
Closes: https://sashiko.dev/#/bug/linux-cbafd8f2-6541-4311-b97b-f7285d2e1992
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/pinctrl/nuvoton/pinctrl-ma35.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/pinctrl/nuvoton/pinctrl-ma35.c b/drivers/pinctrl/nuvoton/pinctrl-ma35.c
index 04528e734bc9..25c66b9e8dd2 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-ma35.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-ma35.c
@@ -518,6 +518,7 @@ static int ma35_gpiolib_register(struct platform_device *pdev, struct ma35_pinct
bank->irqinten = 0;
bank->chip.label = bank->name;
bank->chip.parent = &pdev->dev;
+ bank->chip.fwnode = bank->fwnode;
bank->chip.request = ma35_gpio_core_to_request;
bank->chip.direction_input = ma35_gpio_core_direction_in;
bank->chip.direction_output = ma35_gpio_core_direction_out;
--
2.56.0.567.gdb80ae8cd5-goog
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 04/10] pinctrl: nuvoton: ma35: Avoid leaking map when parent node is missing
2026-11-11 21:51 [PATCH 00/10] pinctrl: Fix resource leaks, out-of-bounds accesses, and error handling (batch 2) Lee Jones
` (2 preceding siblings ...)
2026-11-11 21:51 ` [PATCH 03/10] pinctrl: nuvoton: ma35: Assign fwnode to gpio_chip in ma35_gpiolib_register() Lee Jones
@ 2026-11-11 21:51 ` Lee Jones
2026-11-11 21:51 ` [PATCH 05/10] pinctrl: nuvoton: npcm8xx: Propagate npcm8xx_gpio_register() error in probe Lee Jones
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Lee Jones @ 2026-11-11 21:51 UTC (permalink / raw)
To: lee, Jacky Huang, Shan-Chun Hung, Linus Walleij,
Harshit Mogalapalli, linux-arm-kernel, linux-gpio, linux-kernel
Cc: stable
Commit 3fd976afe974 ("pinctrl: nuvoton: fix a double free in
ma35_pinctrl_dt_node_to_map_func()") removed the kfree(new_map) call on
the !parent error path to avoid a double free, but left *map = new_map
assigned before of_get_parent(np). Because pinctrl_dt_to_map() does not
invoke dt_free_map() when dt_node_to_map() returns an error, new_map is
leaked if of_get_parent(np) returns NULL.
Look up the parent node before allocating new_map, and release the
parent node reference if the allocation fails.
Fixes: 3fd976afe974 ("pinctrl: nuvoton: fix a double free in ma35_pinctrl_dt_node_to_map_func()")
Closes: https://sashiko.dev/#/bug/linux-ae0c2737-0408-4808-9bae-f7389beb51d0
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/pinctrl/nuvoton/pinctrl-ma35.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/pinctrl/nuvoton/pinctrl-ma35.c b/drivers/pinctrl/nuvoton/pinctrl-ma35.c
index 25c66b9e8dd2..4ae1d7ac2b56 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-ma35.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-ma35.c
@@ -201,17 +201,19 @@ static int ma35_pinctrl_dt_node_to_map_func(struct pinctrl_dev *pctldev,
return -EINVAL;
}
+ parent = of_get_parent(np);
+ if (!parent)
+ return -EINVAL;
+
map_num += grp->grp.npins;
new_map = kzalloc_objs(*new_map, map_num);
- if (!new_map)
+ if (!new_map) {
+ of_node_put(parent);
return -ENOMEM;
+ }
*map = new_map;
*num_maps = map_num;
- /* create mux map */
- parent = of_get_parent(np);
- if (!parent)
- return -EINVAL;
setting = grp->data;
--
2.56.0.567.gdb80ae8cd5-goog
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 05/10] pinctrl: nuvoton: npcm8xx: Propagate npcm8xx_gpio_register() error in probe
2026-11-11 21:51 [PATCH 00/10] pinctrl: Fix resource leaks, out-of-bounds accesses, and error handling (batch 2) Lee Jones
` (3 preceding siblings ...)
2026-11-11 21:51 ` [PATCH 04/10] pinctrl: nuvoton: ma35: Avoid leaking map when parent node is missing Lee Jones
@ 2026-11-11 21:51 ` Lee Jones
2026-11-11 21:51 ` [PATCH 06/10] pinctrl: nuvoton: npcm7xx: Fix fwnode_irq_get() error check in npcm7xx_gpio_of() Lee Jones
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Lee Jones @ 2026-11-11 21:51 UTC (permalink / raw)
To: lee, Andrew Jeffery, Avi Fishman, Tomer Maimon, Tali Perry,
Patrick Venture, Nancy Yuen, Benjamin Fair, Linus Walleij,
tomer.maimon, openbmc, linux-gpio, linux-kernel
Cc: stable
npcm8xx_pinctrl_probe() logs an error with dev_err_probe() when
npcm8xx_gpio_register() fails, but omits the return statement and
returns 0 instead. Propagate the error returned by dev_err_probe().
Fixes: acf4884a5717 ("pinctrl: nuvoton: add NPCM8XX pinctrl and GPIO driver")
Closes: https://sashiko.dev/#/bug/linux-cff468bb-80b4-4cb3-a5ff-2b3a8fdb151f
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c b/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c
index 6150cde7e824..8a7cc46b5001 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c
@@ -2583,7 +2583,7 @@ static int npcm8xx_pinctrl_probe(struct platform_device *pdev)
ret = npcm8xx_gpio_register(pctrl);
if (ret < 0)
- dev_err_probe(dev, ret, "Failed to register gpio\n");
+ return dev_err_probe(dev, ret, "Failed to register gpio\n");
return 0;
}
--
2.56.0.567.gdb80ae8cd5-goog
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 06/10] pinctrl: nuvoton: npcm7xx: Fix fwnode_irq_get() error check in npcm7xx_gpio_of()
2026-11-11 21:51 [PATCH 00/10] pinctrl: Fix resource leaks, out-of-bounds accesses, and error handling (batch 2) Lee Jones
` (4 preceding siblings ...)
2026-11-11 21:51 ` [PATCH 05/10] pinctrl: nuvoton: npcm8xx: Propagate npcm8xx_gpio_register() error in probe Lee Jones
@ 2026-11-11 21:51 ` Lee Jones
2026-11-11 21:51 ` [PATCH 07/10] pinctrl: single: Reject invalid register width in pcs_probe() Lee Jones
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Lee Jones @ 2026-11-11 21:51 UTC (permalink / raw)
To: lee, Andrew Jeffery, Avi Fishman, Tomer Maimon, Tali Perry,
Patrick Venture, Nancy Yuen, Benjamin Fair, Linus Walleij,
Maulik Shah, jordan_hargrave, tomer.maimon, Andy Shevchenko,
openbmc, linux-gpio, linux-kernel
Cc: stable
Commit 693c9ecd8326 ("pinctrl: nuvoton: Reduce use of OF-specific APIs")
replaced irq_of_parse_and_map(), which returns 0 on failure, with
fwnode_irq_get(), which returns a negative errno on failure (including
-EPROBE_DEFER), while leaving the !ret check unchanged. As a result,
negative error codes are stored in pctrl->gpio_bank[id].irq as large
unsigned values instead of aborting or deferring probe.
Check for ret < 0 and propagate the error code, matching the NPCM8XX
driver.
Fixes: 693c9ecd8326 ("pinctrl: nuvoton: Reduce use of OF-specific APIs")
Closes: https://sashiko.dev/#/bug/linux-95c9d7d3-32bb-4f4e-ab7f-84872957de4f
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c b/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c
index e051ff141d6c..47cc3ef8ddfd 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c
@@ -1856,9 +1856,10 @@ static int npcm7xx_gpio_of(struct npcm7xx_pinctrl *pctrl)
}
ret = fwnode_irq_get(child, 0);
- if (!ret) {
- dev_err(dev, "No IRQ for GPIO bank %u\n", id);
- return -EINVAL;
+ if (ret < 0) {
+ fwnode_handle_put(child);
+ return dev_err_probe(dev, ret,
+ "No IRQ for GPIO bank %u\n", id);
}
pctrl->gpio_bank[id].irq = ret;
pctrl->gpio_bank[id].irqbase = id * NPCM7XX_GPIO_PER_BANK;
--
2.56.0.567.gdb80ae8cd5-goog
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 07/10] pinctrl: single: Reject invalid register width in pcs_probe()
2026-11-11 21:51 [PATCH 00/10] pinctrl: Fix resource leaks, out-of-bounds accesses, and error handling (batch 2) Lee Jones
` (5 preceding siblings ...)
2026-11-11 21:51 ` [PATCH 06/10] pinctrl: nuvoton: npcm7xx: Fix fwnode_irq_get() error check in npcm7xx_gpio_of() Lee Jones
@ 2026-11-11 21:51 ` Lee Jones
2026-11-11 21:51 ` [PATCH 08/10] pinctrl: single: Free pinconf settings array in pcs_dt_free_map() Lee Jones
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Lee Jones @ 2026-11-11 21:51 UTC (permalink / raw)
To: lee, Tony Lindgren, Haojian Zhuang, Linus Walleij,
linux-arm-kernel, linux-omap, linux-gpio, linux-kernel
Cc: stable
If the "pinctrl-single,register-width" property specifies an unsupported
width (anything other than 8, 16, or 32), pcs_probe() hits the default
branch in the switch statement and continues without initialising
pcs->read or pcs->write, leading to a divide-by-zero in
pcs_allocate_pin_table() or a NULL function pointer dereference when
accessing registers.
Validate pcs->width immediately after reading the property and return
-EINVAL from the default branch in pcs_probe().
Fixes: 8b8b091bf07f ("pinctrl: Add one-register-per-pin type device tree based pinctrl driver")
Closes: https://sashiko.dev/#/bug/linux-a0303b6e-d0c6-4292-aeeb-fa8a21861827
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/pinctrl/pinctrl-single.c | 34 ++++++++++++++++----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index e0eb7240a985..13e0ae8bb389 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -1811,6 +1811,23 @@ static int pcs_probe(struct platform_device *pdev)
return ret;
}
+ switch (pcs->width) {
+ case 8:
+ pcs->read = pcs_readb;
+ pcs->write = pcs_writeb;
+ break;
+ case 16:
+ pcs->read = pcs_readw;
+ pcs->write = pcs_writew;
+ break;
+ case 32:
+ pcs->read = pcs_readl;
+ pcs->write = pcs_writel;
+ break;
+ default:
+ return -EINVAL;
+ }
+
ret = of_property_read_u32(np, "pinctrl-single,function-mask",
&pcs->fmask);
if (!ret) {
@@ -1860,23 +1877,6 @@ static int pcs_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, pcs);
- switch (pcs->width) {
- case 8:
- pcs->read = pcs_readb;
- pcs->write = pcs_writeb;
- break;
- case 16:
- pcs->read = pcs_readw;
- pcs->write = pcs_writew;
- break;
- case 32:
- pcs->read = pcs_readl;
- pcs->write = pcs_writel;
- break;
- default:
- break;
- }
-
pcs->desc.name = DRIVER_NAME;
pcs->desc.pctlops = &pcs_pinctrl_ops;
pcs->desc.pmxops = &pcs_pinmux_ops;
--
2.56.0.567.gdb80ae8cd5-goog
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 08/10] pinctrl: single: Free pinconf settings array in pcs_dt_free_map()
2026-11-11 21:51 [PATCH 00/10] pinctrl: Fix resource leaks, out-of-bounds accesses, and error handling (batch 2) Lee Jones
` (6 preceding siblings ...)
2026-11-11 21:51 ` [PATCH 07/10] pinctrl: single: Reject invalid register width in pcs_probe() Lee Jones
@ 2026-11-11 21:51 ` Lee Jones
2026-11-11 21:51 ` [PATCH 09/10] pinctrl: sunplus: Validate pin_func index in sppctl_dt_node_to_map() Lee Jones
2026-11-11 21:51 ` [PATCH 10/10] pinctrl: realtek: rtd1625: Set dcycle_offset to NA for pins without duty-cycle support Lee Jones
9 siblings, 0 replies; 11+ messages in thread
From: Lee Jones @ 2026-11-11 21:51 UTC (permalink / raw)
To: lee, Tony Lindgren, Haojian Zhuang, Linus Walleij,
linux-arm-kernel, linux-omap, linux-gpio, linux-kernel
Cc: stable
pcs_parse_pinconf() allocates a settings array via devm_kcalloc() on the
pin controller device and attaches it to map[1].data.configs.configs.
When the pinctrl core copies the map entries into its internal tables or
tears down a consumer device mapping, it invokes pcs_dt_free_map(),
which only frees the outer map array and leaves the per-map configs
array allocated on pcs->dev until the pin controller itself is unbound.
Free map[i].data.configs.configs for PIN_MAP_TYPE_CONFIGS_GROUP entries
in pcs_dt_free_map().
Fixes: 9dddb4df90d1 ("pinctrl: single: support generic pinconf")
Closes: https://sashiko.dev/#/bug/linux-fcedec46-4487-4392-a882-3d3bef07e56f
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/pinctrl/pinctrl-single.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 13e0ae8bb389..fcd86dbf6869 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -311,9 +311,13 @@ static void pcs_pin_dbg_show(struct pinctrl_dev *pctldev,
static void pcs_dt_free_map(struct pinctrl_dev *pctldev,
struct pinctrl_map *map, unsigned num_maps)
{
- struct pcs_device *pcs;
+ struct pcs_device *pcs = pinctrl_dev_get_drvdata(pctldev);
+
+ for (unsigned int i = 0; i < num_maps; i++) {
+ if (map[i].type == PIN_MAP_TYPE_CONFIGS_GROUP)
+ devm_kfree(pcs->dev, map[i].data.configs.configs);
+ }
- pcs = pinctrl_dev_get_drvdata(pctldev);
devm_kfree(pcs->dev, map);
}
--
2.56.0.567.gdb80ae8cd5-goog
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 09/10] pinctrl: sunplus: Validate pin_func index in sppctl_dt_node_to_map()
2026-11-11 21:51 [PATCH 00/10] pinctrl: Fix resource leaks, out-of-bounds accesses, and error handling (batch 2) Lee Jones
` (7 preceding siblings ...)
2026-11-11 21:51 ` [PATCH 08/10] pinctrl: single: Free pinconf settings array in pcs_dt_free_map() Lee Jones
@ 2026-11-11 21:51 ` Lee Jones
2026-11-11 21:51 ` [PATCH 10/10] pinctrl: realtek: rtd1625: Set dcycle_offset to NA for pins without duty-cycle support Lee Jones
9 siblings, 0 replies; 11+ messages in thread
From: Lee Jones @ 2026-11-11 21:51 UTC (permalink / raw)
To: lee, Dvorkin Dmitry, Wells Lu, Linus Walleij, Andrew Gaylard,
linux-arm-kernel, linux-gpio, linux-kernel
Cc: stable
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@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 10/10] pinctrl: realtek: rtd1625: Set dcycle_offset to NA for pins without duty-cycle support
2026-11-11 21:51 [PATCH 00/10] pinctrl: Fix resource leaks, out-of-bounds accesses, and error handling (batch 2) Lee Jones
` (8 preceding siblings ...)
2026-11-11 21:51 ` [PATCH 09/10] pinctrl: sunplus: Validate pin_func index in sppctl_dt_node_to_map() Lee Jones
@ 2026-11-11 21:51 ` Lee Jones
9 siblings, 0 replies; 11+ messages in thread
From: Lee Jones @ 2026-11-11 21:51 UTC (permalink / raw)
To: lee, James Tai, Yu-Chun Lin, Andreas Färber, Linus Walleij,
Tzuyi Chang, linux-arm-kernel, linux-realtek-soc, linux-gpio,
linux-kernel
Cc: stable
In rtd1625_main2_sconfigs[], pins gpio_86 through gpio_91 do not support
clock duty-cycle adjustment (dcycle_maskbits is 0), but specify 0
instead of NA for dcycle_offset. Because rtd_pconf_parse_conf() tests
sconfig_desc->dcycle_offset == NA to determine whether duty-cycle
configuration is supported, an offset of 0 causes it to compute
GENMASK(0 - 1, 0) and corrupt the pad control register.
Set dcycle_offset to NA for gpio_86 through gpio_91.
Fixes: e309dbd523b8 ("pinctrl: realtek: add rtd1625 pinctrl driver")
Closes: https://sashiko.dev/#/bug/linux-8a8f690f-15e7-4dbd-a3a2-87bc00edf7b9
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/pinctrl/realtek/pinctrl-rtd1625.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/pinctrl/realtek/pinctrl-rtd1625.c b/drivers/pinctrl/realtek/pinctrl-rtd1625.c
index 88f2be37f743..f6e038e4bbdd 100644
--- a/drivers/pinctrl/realtek/pinctrl-rtd1625.c
+++ b/drivers/pinctrl/realtek/pinctrl-rtd1625.c
@@ -2993,12 +2993,12 @@ static const struct rtd_pin_sconfig_desc rtd1625_main2_sconfigs[] = {
RTK_PIN_SCONFIG(gpio_65, 0x34, 16, 3, 19, 3, 22, 3),
RTK_PIN_SCONFIG(gpio_66, 0x38, 3, 3, 6, 3, 9, 3),
RTK_PIN_SCONFIG(gpio_67, 0x38, 16, 3, 19, 3, 22, 3),
- RTK_PIN_SCONFIG(gpio_86, 0x3c, 0, 0, 14, 4, 18, 4),
- RTK_PIN_SCONFIG(gpio_87, 0x3c, 0, 0, 24, 4, 28, 4),
- RTK_PIN_SCONFIG(gpio_88, 0x40, 0, 0, 2, 4, 6, 4),
- RTK_PIN_SCONFIG(gpio_89, 0x40, 0, 0, 12, 4, 16, 4),
- RTK_PIN_SCONFIG(gpio_90, 0x40, 0, 0, 22, 4, 26, 4),
- RTK_PIN_SCONFIG(gpio_91, 0x44, 0, 0, 2, 4, 6, 4),
+ RTK_PIN_SCONFIG(gpio_86, 0x3c, NA, 0, 14, 4, 18, 4),
+ RTK_PIN_SCONFIG(gpio_87, 0x3c, NA, 0, 24, 4, 28, 4),
+ RTK_PIN_SCONFIG(gpio_88, 0x40, NA, 0, 2, 4, 6, 4),
+ RTK_PIN_SCONFIG(gpio_89, 0x40, NA, 0, 12, 4, 16, 4),
+ RTK_PIN_SCONFIG(gpio_90, 0x40, NA, 0, 22, 4, 26, 4),
+ RTK_PIN_SCONFIG(gpio_91, 0x44, NA, 0, 2, 4, 6, 4),
RTK_PIN_SCONFIG(hif_clk, 0x44, 13, 3, 16, 3, 19, 3),
RTK_PIN_SCONFIG(hif_data, 0x48, 3, 3, 6, 3, 9, 3),
RTK_PIN_SCONFIG(hif_en, 0x48, 16, 3, 19, 3, 22, 3),
--
2.56.0.567.gdb80ae8cd5-goog
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-11-11 21:54 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-11 21:51 [PATCH 00/10] pinctrl: Fix resource leaks, out-of-bounds accesses, and error handling (batch 2) Lee Jones
2026-11-11 21:51 ` [PATCH 01/10] pinctrl: nuvoton: ma35: Unmap reg_base and release clock on probe error Lee Jones
2026-11-11 21:51 ` [PATCH 02/10] pinctrl: nuvoton: ma35: Prevent out-of-bounds write in ma35_pinctrl_get_soc_data() Lee Jones
2026-11-11 21:51 ` [PATCH 03/10] pinctrl: nuvoton: ma35: Assign fwnode to gpio_chip in ma35_gpiolib_register() Lee Jones
2026-11-11 21:51 ` [PATCH 04/10] pinctrl: nuvoton: ma35: Avoid leaking map when parent node is missing Lee Jones
2026-11-11 21:51 ` [PATCH 05/10] pinctrl: nuvoton: npcm8xx: Propagate npcm8xx_gpio_register() error in probe Lee Jones
2026-11-11 21:51 ` [PATCH 06/10] pinctrl: nuvoton: npcm7xx: Fix fwnode_irq_get() error check in npcm7xx_gpio_of() Lee Jones
2026-11-11 21:51 ` [PATCH 07/10] pinctrl: single: Reject invalid register width in pcs_probe() Lee Jones
2026-11-11 21:51 ` [PATCH 08/10] pinctrl: single: Free pinconf settings array in pcs_dt_free_map() Lee Jones
2026-11-11 21:51 ` [PATCH 09/10] pinctrl: sunplus: Validate pin_func index in sppctl_dt_node_to_map() Lee Jones
2026-11-11 21:51 ` [PATCH 10/10] pinctrl: realtek: rtd1625: Set dcycle_offset to NA for pins without duty-cycle support Lee Jones
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®