Skip to contentSkip to conversation

pinctrl: nomadik: Fix refcount leak in nmk_pinctrl_dt_subnode_to_map

PATCH In review Miaoqian Lin 2 participants 2 messages Jun 7, 2022 – Jun 15, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pinctrl: nomadik: Fix refcount leak in nmk_pinctrl_dt_subnode_to_map

of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Add missing of_node_put() to avoid refcount leak."

Fixes c2f6d059abfc ("pinctrl: nomadik: refactor DT parser to take two paths")
---
 drivers/pinctrl/nomadik/pinctrl-nomadik.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pinctrl/nomadik/pinctrl-nomadik.c +3 -1
index 640e50d94f27..f5014d09d81a 100644
@@ -1421,8 +1421,10 @@ static int nmk_pinctrl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
 
 	has_config = nmk_pinctrl_dt_get_config(np, &configs);
 	np_config = of_parse_phandle(np, "ste,config", 0);
-	if (np_config)
+	if (np_config) {
 		has_config |= nmk_pinctrl_dt_get_config(np_config, &configs);
+		of_node_put(np_config);
+	}
 	if (has_config) {
 		const char *gpio_name;
 		const char *pin;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 6 lines · Miaoqian Lin

of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Add missing of_node_put() to avoid refcount leak."

Fixes c2f6d059abfc ("pinctrl: nomadik: refactor DT parser to take two paths")

Patch applied!

Yours,
Linus Walleij