linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: shmobile: Add missing of_node_put()
@ 2021-10-18  1:45 Wan Jiabing
  2021-10-18 11:25 ` Geert Uytterhoeven
  0 siblings, 1 reply; 2+ messages in thread
From: Wan Jiabing @ 2021-10-18  1:45 UTC (permalink / raw)
  To: Geert Uytterhoeven, Magnus Damm, Russell King, linux-arm-kernel,
	linux-renesas-soc, linux-kernel
  Cc: kael_w, Wan Jiabing

Fix following coccicheck warning:
./arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c:156:1-33: Function
for_each_matching_node_and_match should have of_node_put() before break
and goto.

Early exits from for_each_matching_node_and_match should decrement the
node reference counter.

Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
---
 arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c
index ee949255ced3..09ef73b99dd8 100644
--- a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c
+++ b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c
@@ -154,8 +154,10 @@ static int __init rcar_gen2_regulator_quirk(void)
 		return -ENODEV;
 
 	for_each_matching_node_and_match(np, rcar_gen2_quirk_match, &id) {
-		if (!of_device_is_available(np))
+		if (!of_device_is_available(np)) {
+			of_node_put(np);
 			break;
+		}
 
 		ret = of_property_read_u32(np, "reg", &addr);
 		if (ret)	/* Skip invalid entry and continue */
@@ -164,6 +166,7 @@ static int __init rcar_gen2_regulator_quirk(void)
 		quirk = kzalloc(sizeof(*quirk), GFP_KERNEL);
 		if (!quirk) {
 			ret = -ENOMEM;
+			of_node_put(np);
 			goto err_mem;
 		}
 
-- 
2.20.1


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

* Re: [PATCH] ARM: shmobile: Add missing of_node_put()
  2021-10-18  1:45 [PATCH] ARM: shmobile: Add missing of_node_put() Wan Jiabing
@ 2021-10-18 11:25 ` Geert Uytterhoeven
  0 siblings, 0 replies; 2+ messages in thread
From: Geert Uytterhoeven @ 2021-10-18 11:25 UTC (permalink / raw)
  To: Wan Jiabing
  Cc: Magnus Damm, Russell King, Linux ARM, Linux-Renesas,
	Linux Kernel Mailing List, kael_w

On Mon, Oct 18, 2021 at 3:45 AM Wan Jiabing <wanjiabing@vivo.com> wrote:
> Fix following coccicheck warning:
> ./arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c:156:1-33: Function
> for_each_matching_node_and_match should have of_node_put() before break
> and goto.
>
> Early exits from for_each_matching_node_and_match should decrement the
> node reference counter.
>
> Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
i.e. will queue in renesas-devel for v5.17.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

end of thread, other threads:[~2021-10-18 11:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-18  1:45 [PATCH] ARM: shmobile: Add missing of_node_put() Wan Jiabing
2021-10-18 11:25 ` Geert Uytterhoeven

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).