mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] pinctrl: aspeed-g5: fix device node leak on LPC compatible mismatch
@ 2026-10-09  4:14 Haotian Zhang
  2026-10-09  6:10 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 2+ messages in thread
From: Haotian Zhang @ 2026-10-09  4:14 UTC (permalink / raw)
  To: Andrew Jeffery, Linus Walleij, Joel Stanley, Ryan Chen,
	Billy Tsai, Chia-Wei, Wang
  Cc: linux-aspeed, openbmc, linux-gpio, linux-arm-kernel, linux-kernel

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@iscas.ac.cn>
---
 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


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

end of thread, other threads:[~2026-10-09  6:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-09  4:14 [PATCH] pinctrl: aspeed-g5: fix device node leak on LPC compatible mismatch Haotian Zhang
2026-10-09  6:10 ` Krzysztof Kozlowski

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®