All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Julia Lawall <Julia.Lawall@lip6.fr>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Sasha Levin <sashal@kernel.org>,
	nick.child@ibm.com, linuxppc-dev@lists.ozlabs.org
Subject: [PATCH AUTOSEL 4.9 04/13] powerpc/btext: add missing of_node_put
Date: Mon, 17 Jan 2022 12:07:12 -0500	[thread overview]
Message-ID: <20220117170722.1473137-4-sashal@kernel.org> (raw)
In-Reply-To: <20220117170722.1473137-1-sashal@kernel.org>

From: Julia Lawall <Julia.Lawall@lip6.fr>

[ Upstream commit a1d2b210ffa52d60acabbf7b6af3ef7e1e69cda0 ]

for_each_node_by_type performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.

A simplified version of the semantic patch that fixes this problem is as
follows (http://coccinelle.lip6.fr):

// <smpl>
@@
local idexpression n;
expression e;
@@

 for_each_node_by_type(n,...) {
   ...
(
   of_node_put(n);
|
   e = n
|
+  of_node_put(n);
?  break;
)
   ...
 }
... when != n
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/1448051604-25256-6-git-send-email-Julia.Lawall@lip6.fr
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/powerpc/kernel/btext.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/btext.c b/arch/powerpc/kernel/btext.c
index 8275858a434d9..2d91ba38b4524 100644
--- a/arch/powerpc/kernel/btext.c
+++ b/arch/powerpc/kernel/btext.c
@@ -257,8 +257,10 @@ int __init btext_find_display(int allow_nonstdout)
 			rc = btext_initialize(np);
 			printk("result: %d\n", rc);
 		}
-		if (rc == 0)
+		if (rc == 0) {
+			of_node_put(np);
 			break;
+		}
 	}
 	return rc;
 }
-- 
2.34.1


WARNING: multiple messages have this Message-ID (diff)
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Sasha Levin <sashal@kernel.org>,
	Julia Lawall <Julia.Lawall@lip6.fr>,
	linuxppc-dev@lists.ozlabs.org, nick.child@ibm.com
Subject: [PATCH AUTOSEL 4.9 04/13] powerpc/btext: add missing of_node_put
Date: Mon, 17 Jan 2022 12:07:12 -0500	[thread overview]
Message-ID: <20220117170722.1473137-4-sashal@kernel.org> (raw)
In-Reply-To: <20220117170722.1473137-1-sashal@kernel.org>

From: Julia Lawall <Julia.Lawall@lip6.fr>

[ Upstream commit a1d2b210ffa52d60acabbf7b6af3ef7e1e69cda0 ]

for_each_node_by_type performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.

A simplified version of the semantic patch that fixes this problem is as
follows (http://coccinelle.lip6.fr):

// <smpl>
@@
local idexpression n;
expression e;
@@

 for_each_node_by_type(n,...) {
   ...
(
   of_node_put(n);
|
   e = n
|
+  of_node_put(n);
?  break;
)
   ...
 }
... when != n
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/1448051604-25256-6-git-send-email-Julia.Lawall@lip6.fr
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/powerpc/kernel/btext.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/btext.c b/arch/powerpc/kernel/btext.c
index 8275858a434d9..2d91ba38b4524 100644
--- a/arch/powerpc/kernel/btext.c
+++ b/arch/powerpc/kernel/btext.c
@@ -257,8 +257,10 @@ int __init btext_find_display(int allow_nonstdout)
 			rc = btext_initialize(np);
 			printk("result: %d\n", rc);
 		}
-		if (rc == 0)
+		if (rc == 0) {
+			of_node_put(np);
 			break;
+		}
 	}
 	return rc;
 }
-- 
2.34.1


  parent reply	other threads:[~2022-01-17 17:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-17 17:07 [PATCH AUTOSEL 4.9 01/13] powerpc/6xx: add missing of_node_put Sasha Levin
2022-01-17 17:07 ` Sasha Levin
2022-01-17 17:07 ` [PATCH AUTOSEL 4.9 02/13] powerpc/powernv: " Sasha Levin
2022-01-17 17:07   ` Sasha Levin
2022-01-17 17:07 ` [PATCH AUTOSEL 4.9 03/13] powerpc/cell: " Sasha Levin
2022-01-17 17:07   ` Sasha Levin
2022-01-17 17:07 ` Sasha Levin [this message]
2022-01-17 17:07   ` [PATCH AUTOSEL 4.9 04/13] powerpc/btext: " Sasha Levin
2022-01-17 17:07 ` [PATCH AUTOSEL 4.9 05/13] i2c: i801: Don't silently correct invalid transfer size Sasha Levin
2022-01-17 17:07 ` [PATCH AUTOSEL 4.9 06/13] powerpc/smp: Move setup_profiling_timer() under CONFIG_PROFILING Sasha Levin
2022-01-17 17:07   ` Sasha Levin
2022-01-17 17:07 ` [PATCH AUTOSEL 4.9 07/13] i2c: mpc: Correct I2C reset procedure Sasha Levin
2022-01-17 17:07 ` [PATCH AUTOSEL 4.9 08/13] w1: Misuse of get_user()/put_user() reported by sparse Sasha Levin
2022-01-17 17:07 ` [PATCH AUTOSEL 4.9 09/13] ALSA: seq: Set upper limit of processed events Sasha Levin
2022-01-17 17:07   ` Sasha Levin
2022-01-17 17:07 ` [PATCH AUTOSEL 4.9 10/13] i2c: designware-pci: Fix to change data types of hcnt and lcnt parameters Sasha Levin
2022-01-17 17:07 ` [PATCH AUTOSEL 4.9 11/13] MIPS: Octeon: Fix build errors using clang Sasha Levin
2022-01-17 17:07 ` [PATCH AUTOSEL 4.9 12/13] scsi: sr: Don't use GFP_DMA Sasha Levin
2022-01-17 17:07 ` [PATCH AUTOSEL 4.9 13/13] ASoC: mediatek: mt8173: fix device_node leak Sasha Levin
2022-01-17 17:07   ` Sasha Levin
2022-01-17 17:07   ` Sasha Levin
2022-01-17 17:07   ` Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220117170722.1473137-4-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=Julia.Lawall@lip6.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=nick.child@ibm.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.