[PATCH] pinctrl: aspeed-g5: fix device node leak on LPC compatible mismatch
From: Haotian Zhang
Date: Fri Oct 09 2026 - 00:15:08 EST
aspeed_g5_acquire_regmap() takes a reference to the LPC device node with
of_parse_phandle() and then returns -ENODEV if the node's parent is not
compatible with "aspeed,ast2500-lpc-v2", without dropping that
reference. The function is called for every pin configuration, so the
leaked device_node reference accumulates on such systems.
Release the node with of_node_put() before returning from the error path.
Fixes: eaffd32bea0c ("pinctrl: aspeed-g5: Adapt to new LPC device tree layout")
Assisted-by: DeepSeek-V4.1-Flash
Signed-off-by: Haotian Zhang <vulab@xxxxxxxxxxx>
---
drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
index b0cba0f3e17e..6ab3ba89bd54 100644
--- a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
+++ b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
@@ -2652,8 +2652,11 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
np = of_parse_phandle(ctx->dev->of_node,
"aspeed,external-nodes", 1);
if (np) {
- if (!of_device_is_compatible(np->parent, "aspeed,ast2500-lpc-v2"))
+ if (!of_device_is_compatible(np->parent,
+ "aspeed,ast2500-lpc-v2")) {
+ of_node_put(np);
return ERR_PTR(-ENODEV);
+ }
map = syscon_node_to_regmap(np->parent);
of_node_put(np);
--
2.25.1