* [PATCH v3 01/12] pinctrl: nuvoton: ma35: Unmap reg_base and release clock on probe error
2026-11-27 14:04 [PATCH v3 00/12] pinctrl: Fix memory leaks, OOB writes, and resource handling bugs Lee Jones
@ 2026-11-27 14:04 ` Lee Jones
2026-11-27 14:04 ` [PATCH v3 02/12] pinctrl: nuvoton: ma35: Prevent out-of-bounds write in ma35_pinctrl_get_soc_data() Lee Jones
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2026-11-27 14:04 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>
---
v2 => v3:
- Rebase onto pinctrl/for-next; no functional changes.
drivers/pinctrl/nuvoton/pinctrl-ma35.c | 37 ++++++++++++++++++++++----
1 file changed, 32 insertions(+), 5 deletions(-)
diff --git a/drivers/pinctrl/nuvoton/pinctrl-ma35.c b/drivers/pinctrl/nuvoton/pinctrl-ma35.c
index 564ec0aa4287..872769db244b 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-ma35.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-ma35.c
@@ -11,6 +11,7 @@
#include <linux/cleanup.h>
#include <linux/clk.h>
#include <linux/gpio/driver.h>
+#include <linux/io.h>
#include <linux/mfd/syscon.h>
#include <linux/of.h>
#include <linux/platform_device.h>
@@ -556,6 +557,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;
@@ -564,6 +581,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;
@@ -573,10 +594,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)
@@ -584,7 +607,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;
@@ -604,8 +627,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.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v3 02/12] pinctrl: nuvoton: ma35: Prevent out-of-bounds write in ma35_pinctrl_get_soc_data()
2026-11-27 14:04 [PATCH v3 00/12] pinctrl: Fix memory leaks, OOB writes, and resource handling bugs Lee Jones
2026-11-27 14:04 ` [PATCH v3 01/12] pinctrl: nuvoton: ma35: Unmap reg_base and release clock on probe error Lee Jones
@ 2026-11-27 14:04 ` Lee Jones
2026-11-27 14:04 ` [PATCH v3 03/12] pinctrl: nuvoton: ma35: Retain child firmware node reference " Lee Jones
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2026-11-27 14:04 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>
---
v2 => v3:
- Rebase onto pinctrl/for-next; no functional changes.
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 872769db244b..ddd3f4329f67 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-ma35.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-ma35.c
@@ -623,6 +623,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.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v3 03/12] pinctrl: nuvoton: ma35: Retain child firmware node reference in ma35_pinctrl_get_soc_data()
2026-11-27 14:04 [PATCH v3 00/12] pinctrl: Fix memory leaks, OOB writes, and resource handling bugs Lee Jones
2026-11-27 14:04 ` [PATCH v3 01/12] pinctrl: nuvoton: ma35: Unmap reg_base and release clock on probe error Lee Jones
2026-11-27 14:04 ` [PATCH v3 02/12] pinctrl: nuvoton: ma35: Prevent out-of-bounds write in ma35_pinctrl_get_soc_data() Lee Jones
@ 2026-11-27 14:04 ` Lee Jones
2026-11-27 14:04 ` [PATCH v3 04/12] pinctrl: nuvoton: ma35: Assign fwnode to gpio_chip in ma35_gpiolib_register() Lee Jones
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2026-11-27 14:04 UTC (permalink / raw)
To: lee, Jacky Huang, Shan-Chun Hung, Linus Walleij, linux-arm-kernel,
linux-gpio, linux-kernel
Cc: stable
for_each_gpiochip_node() drops its reference on each child firmware node
as the loop advances. Storing child directly in bank->fwnode without
acquiring a reference leaves bank->fwnode dangling once the iteration
moves on, leading to a use-after-free when ma35_gpiolib_register()
accesses bank->fwnode.
Acquire a reference on child with fwnode_handle_get() and register a
devres action to release it on probe failure or device teardown.
Fixes: f805e356313b ("pinctrl: nuvoton: Add ma35d1 pinctrl and GPIO driver")
Closes: https://sashiko.dev/#/bug/linux-f140abe2-145a-4f6b-b626-bbabdc7327c4
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
v2 => v3:
- Rebase onto pinctrl/for-next; no functional changes.
drivers/pinctrl/nuvoton/pinctrl-ma35.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/nuvoton/pinctrl-ma35.c b/drivers/pinctrl/nuvoton/pinctrl-ma35.c
index ddd3f4329f67..797b4dece7b1 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-ma35.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-ma35.c
@@ -557,6 +557,11 @@ static int ma35_gpiolib_register(struct platform_device *pdev, struct ma35_pinct
return 0;
}
+static void ma35_bank_fwnode_release(void *data)
+{
+ fwnode_handle_put(data);
+}
+
static void ma35_bank_iounmap(void *data)
{
struct ma35_pin_bank *bank = data;
@@ -630,7 +635,14 @@ static int ma35_pinctrl_get_soc_data(struct ma35_pinctrl *pctl, struct platform_
return -EINVAL;
}
bank = &ctrl->pin_banks[id];
- bank->fwnode = child;
+ bank->fwnode = fwnode_handle_get(child);
+ ret = devm_add_action_or_reset(&pdev->dev,
+ ma35_bank_fwnode_release,
+ bank->fwnode);
+ if (ret) {
+ fwnode_handle_put(child);
+ return ret;
+ }
bank->regmap = pctl->regmap;
bank->dev = &pdev->dev;
ret = ma35_get_bank_data(bank);
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v3 04/12] pinctrl: nuvoton: ma35: Assign fwnode to gpio_chip in ma35_gpiolib_register()
2026-11-27 14:04 [PATCH v3 00/12] pinctrl: Fix memory leaks, OOB writes, and resource handling bugs Lee Jones
` (2 preceding siblings ...)
2026-11-27 14:04 ` [PATCH v3 03/12] pinctrl: nuvoton: ma35: Retain child firmware node reference " Lee Jones
@ 2026-11-27 14:04 ` Lee Jones
2026-11-27 14:04 ` [PATCH v3 05/12] pinctrl: nuvoton: ma35: Avoid leaking map when parent node is missing Lee Jones
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2026-11-27 14:04 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>
---
v2 => v3:
- Rebase onto pinctrl/for-next; no functional changes.
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 797b4dece7b1..b6411fc4d98b 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-ma35.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-ma35.c
@@ -519,6 +519,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.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v3 05/12] pinctrl: nuvoton: ma35: Avoid leaking map when parent node is missing
2026-11-27 14:04 [PATCH v3 00/12] pinctrl: Fix memory leaks, OOB writes, and resource handling bugs Lee Jones
` (3 preceding siblings ...)
2026-11-27 14:04 ` [PATCH v3 04/12] pinctrl: nuvoton: ma35: Assign fwnode to gpio_chip in ma35_gpiolib_register() Lee Jones
@ 2026-11-27 14:04 ` Lee Jones
2026-11-27 14:04 ` [PATCH v3 09/12] pinctrl: single: Reject invalid register width in pcs_probe() Lee Jones
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2026-11-27 14:04 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()") switched new_map from
devm_kcalloc() to unmanaged kcalloc() without freeing new_map on the
!parent error path. 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() 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>
---
v2 => v3:
- Rebase onto pinctrl/for-next; no functional changes.
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 b6411fc4d98b..c20350bc1cdb 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-ma35.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-ma35.c
@@ -202,17 +202,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.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v3 09/12] pinctrl: single: Reject invalid register width in pcs_probe()
2026-11-27 14:04 [PATCH v3 00/12] pinctrl: Fix memory leaks, OOB writes, and resource handling bugs Lee Jones
` (4 preceding siblings ...)
2026-11-27 14:04 ` [PATCH v3 05/12] pinctrl: nuvoton: ma35: Avoid leaking map when parent node is missing Lee Jones
@ 2026-11-27 14:04 ` Lee Jones
2026-11-27 14:04 ` [PATCH v3 10/12] pinctrl: single: Free pinconf settings array with pinctrl_utils_free_map() Lee Jones
2026-11-27 14:05 ` [PATCH v3 12/12] pinctrl: realtek: rtd1625: Set dcycle_offset to NA for pins without duty-cycle support Lee Jones
7 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2026-11-27 14:04 UTC (permalink / raw)
To: lee, Tony Lindgren, Haojian Zhuang, Linus Walleij,
linux-arm-kernel, linux-omap, linux-gpio, linux-kernel
Cc: stable, Alexander Sverdlin
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
Reviewed-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
Signed-off-by: Lee Jones <lee@kernel.org>
---
v2 => v3:
- Add Reviewed-by tag from Alexander Sverdlin.
- Rebase onto pinctrl/for-next.
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 52734bd7b7f0..6f5113dcdb4b 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -1827,6 +1827,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) {
@@ -1876,23 +1893,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.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v3 10/12] pinctrl: single: Free pinconf settings array with pinctrl_utils_free_map()
2026-11-27 14:04 [PATCH v3 00/12] pinctrl: Fix memory leaks, OOB writes, and resource handling bugs Lee Jones
` (5 preceding siblings ...)
2026-11-27 14:04 ` [PATCH v3 09/12] pinctrl: single: Reject invalid register width in pcs_probe() Lee Jones
@ 2026-11-27 14:04 ` Lee Jones
2026-11-27 14:05 ` [PATCH v3 12/12] pinctrl: realtek: rtd1625: Set dcycle_offset to NA for pins without duty-cycle support Lee Jones
7 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2026-11-27 14:04 UTC (permalink / raw)
To: lee, Tony Lindgren, Haojian Zhuang, Linus Walleij, Dan Carpenter,
Yang Yingliang, linux-arm-kernel, linux-omap, linux-gpio,
linux-kernel
Cc: stable
pcs_parse_pinconf() allocates a per-map settings array and attaches it
to map[i].data.configs.configs, while pcs_dt_node_to_map() allocates
*map itself, both via devm_kzalloc_objs() on pcs->dev.
When a consumer device unbinds and re-probes, pcs_dt_free_map() only
frees map and leaks the settings array on pcs->dev. Moreover, because
pcs_probe() registers the pinctrl device with devres before pinctrl
hogs or consumers call pcs_dt_node_to_map(), devres teardown on
pcs->dev unbind frees *map and settings before
devm_pinctrl_dev_release() invokes .dt_free_map().
Allocate *map and settings with unmanaged kzalloc_objs() and wire
.dt_free_map directly to pinctrl_utils_free_map(), dropping the custom
pcs_dt_free_map() callback.
Fixes: 8f773bfbdd42 ("pinctrl: single: fix possible memory leak when pinctrl_enable() fails")
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>
---
v2 => v3:
- Allocate the pinconf settings array with kzalloc_objs() and wire .dt_free_map directly to pinctrl_utils_free_map(), dropping pcs_dt_free_map(), per Alexander Sverdlin's review.
- Update the first Fixes tag to commit 8f773bfbdd42 ("pinctrl: single: fix possible memory leak when pinctrl_enable() fails").
drivers/pinctrl/pinctrl-single.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 6f5113dcdb4b..3f756796c792 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -32,6 +32,7 @@
#include "core.h"
#include "devicetree.h"
#include "pinconf.h"
+#include "pinctrl-utils.h"
#include "pinmux.h"
#define DRIVER_NAME "pinctrl-single"
@@ -308,15 +309,6 @@ static void pcs_pin_dbg_show(struct pinctrl_dev *pctldev,
seq_printf(s, "%zx %08x %s ", pa, val, DRIVER_NAME);
}
-static void pcs_dt_free_map(struct pinctrl_dev *pctldev,
- struct pinctrl_map *map, unsigned num_maps)
-{
- struct pcs_device *pcs;
-
- pcs = pinctrl_dev_get_drvdata(pctldev);
- devm_kfree(pcs->dev, map);
-}
-
static int pcs_dt_node_to_map(struct pinctrl_dev *pctldev,
struct device_node *np_config,
struct pinctrl_map **map, unsigned *num_maps);
@@ -327,7 +319,7 @@ static const struct pinctrl_ops pcs_pinctrl_ops = {
.get_group_pins = pinctrl_generic_get_group_pins,
.pin_dbg_show = pcs_pin_dbg_show,
.dt_node_to_map = pcs_dt_node_to_map,
- .dt_free_map = pcs_dt_free_map,
+ .dt_free_map = pinctrl_utils_free_map,
};
static int pcs_get_function(struct pinctrl_dev *pctldev, unsigned pin,
@@ -960,7 +952,7 @@ static int pcs_parse_pinconf(struct pcs_device *pcs, struct device_node *np,
func->nconfs = nconfs;
conf = &(func->conf[0]);
m++;
- settings = devm_kzalloc_objs(pcs->dev, unsigned long, nconfs);
+ settings = kzalloc_objs(unsigned long, nconfs);
if (!settings)
return -ENOMEM;
s = &settings[0];
@@ -1284,7 +1276,7 @@ static int pcs_dt_node_to_map(struct pinctrl_dev *pctldev,
pcs = pinctrl_dev_get_drvdata(pctldev);
/* create 2 maps. One is for pinmux, and the other is for pinconf. */
- *map = devm_kzalloc_objs(pcs->dev, **map, 2);
+ *map = kzalloc_objs(**map, 2);
if (!*map)
return -ENOMEM;
@@ -1319,7 +1311,7 @@ static int pcs_dt_node_to_map(struct pinctrl_dev *pctldev,
free_pgnames:
devm_kfree(pcs->dev, pgnames);
free_map:
- devm_kfree(pcs->dev, *map);
+ kfree(*map);
return ret;
}
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v3 12/12] pinctrl: realtek: rtd1625: Set dcycle_offset to NA for pins without duty-cycle support
2026-11-27 14:04 [PATCH v3 00/12] pinctrl: Fix memory leaks, OOB writes, and resource handling bugs Lee Jones
` (6 preceding siblings ...)
2026-11-27 14:04 ` [PATCH v3 10/12] pinctrl: single: Free pinconf settings array with pinctrl_utils_free_map() Lee Jones
@ 2026-11-27 14:05 ` Lee Jones
7 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2026-11-27 14:05 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
Reviewed-by: Yu-Chun Lin <eleanor.lin@realtek.com>
Signed-off-by: Lee Jones <lee@kernel.org>
---
v2 => v3:
- Rebase onto pinctrl/for-next; no functional changes.
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.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 9+ messages in thread