Skip to contentSkip to conversation

pinctrl: samsung: exynos: Add of_node_put() before return

PATCH Applied Nishka Dasgupta 2 participants 3 messages Aug 4, 2019 – Oct 1, 2019

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

PATCH 1/1 pinctrl: samsung: exynos: Add of_node_put() before return

Each iteration of for_each_child_of_node puts the previous node, but in the case of a return from the middle of the loop, there is no put, thus causing a memory leak. Hence add an of_node_put before the return. Issue found with Coccinelle.

---
 drivers/pinctrl/samsung/pinctrl-exynos.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pinctrl/samsung/pinctrl-exynos.c +3 -1
index ebc27b06718c..e7f4cbad2c92 100644
@@ -486,8 +486,10 @@ int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 		if (match) {
 			irq_chip = kmemdup(match->data,
 				sizeof(*irq_chip), GFP_KERNEL);
-			if (!irq_chip)
+			if (!irq_chip) {
+				of_node_put(np);
 				return -ENOMEM;
+			}
 			wkup_np = np;
 			break;
 		}
Signature · 1 line
2.19.1
maintainer Applied
#1 lore raw
Quoted 8 lines · Nishka Dasgupta

Each iteration of for_each_child_of_node puts the previous node, but in the case of a return from the middle of the loop, there is no put, thus causing a memory leak. Hence add an of_node_put before the return. Issue found with Coccinelle.

---
 drivers/pinctrl/samsung/pinctrl-exynos.c | 4 +++-

Thanks, applied.

Best regards,
Krzysztof

#2 lore raw
Quoted 6 lines · Krzysztof Kozlowski
Quoted 5 lines · Nishka Dasgupta

Each iteration of for_each_child_of_node puts the previous node, but in the case of a return from the middle of the loop, there is no put, thus causing a memory leak. Hence add an of_node_put before the return. Issue found with Coccinelle.

Quoted 6 lines
Quoted 3 lines
---
 drivers/pinctrl/samsung/pinctrl-exynos.c | 4 +++-

Thanks, applied.

Hi Nishka,

I am sorry but I missed the v5.4 merge window and did not push this to Linus. It's my fault. I'll push it this time, for v5.5 (no need for action from your side).

Best regards,
Krzysztof