linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: samsung: exynos: Add of_node_put() before return
@ 2019-08-04 16:02 Nishka Dasgupta
  2019-08-05 16:21 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 3+ messages in thread
From: Nishka Dasgupta @ 2019-08-04 16:02 UTC (permalink / raw)
  To: linus.walleij, linux-arm-kernel, linux-gpio, tomasz.figa, krzk,
	s.nawrocki, kgene, linux-samsung-soc
  Cc: 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.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
---
 drivers/pinctrl/samsung/pinctrl-exynos.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c
index ebc27b06718c..e7f4cbad2c92 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos.c
+++ b/drivers/pinctrl/samsung/pinctrl-exynos.c
@@ -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;
 		}
-- 
2.19.1


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

* Re: [PATCH] pinctrl: samsung: exynos: Add of_node_put() before return
  2019-08-04 16:02 [PATCH] pinctrl: samsung: exynos: Add of_node_put() before return Nishka Dasgupta
@ 2019-08-05 16:21 ` Krzysztof Kozlowski
  2019-10-01 19:32   ` Krzysztof Kozlowski
  0 siblings, 1 reply; 3+ messages in thread
From: Krzysztof Kozlowski @ 2019-08-05 16:21 UTC (permalink / raw)
  To: Nishka Dasgupta
  Cc: linus.walleij, linux-arm-kernel, linux-gpio, tomasz.figa,
	s.nawrocki, kgene, linux-samsung-soc

On Sun, Aug 04, 2019 at 09:32:00PM +0530, Nishka Dasgupta wrote:
> 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.
> 
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
> ---
>  drivers/pinctrl/samsung/pinctrl-exynos.c | 4 +++-

Thanks, applied.

Best regards,
Krzysztof


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

* Re: [PATCH] pinctrl: samsung: exynos: Add of_node_put() before return
  2019-08-05 16:21 ` Krzysztof Kozlowski
@ 2019-10-01 19:32   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2019-10-01 19:32 UTC (permalink / raw)
  To: Nishka Dasgupta
  Cc: linus.walleij, linux-arm-kernel, linux-gpio, tomasz.figa,
	s.nawrocki, kgene, linux-samsung-soc

On Mon, Aug 05, 2019 at 06:21:54PM +0200, Krzysztof Kozlowski wrote:
> On Sun, Aug 04, 2019 at 09:32:00PM +0530, Nishka Dasgupta wrote:
> > 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.
> > 
> > Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
> > ---
> >  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

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

end of thread, other threads:[~2019-10-01 19:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-04 16:02 [PATCH] pinctrl: samsung: exynos: Add of_node_put() before return Nishka Dasgupta
2019-08-05 16:21 ` Krzysztof Kozlowski
2019-10-01 19:32   ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).