linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powermac: Call of_node_put(bk_node) only once in pmac_has_backlight_type()
@ 2024-10-02 20:02 Markus Elfring
  2024-10-02 20:43 ` Christophe Leroy
  0 siblings, 1 reply; 10+ messages in thread
From: Markus Elfring @ 2024-10-02 20:02 UTC (permalink / raw)
  To: linuxppc-dev, Christophe Leroy, Jani Nikula, Madhavan Srinivasan,
	Michael Ellerman, Naveen N Rao, Nicholas Piggin, Paul Mackerras,
	Stephen Rothwell, Thomas Zimmermann
  Cc: LKML, kernel-janitors, Krzysztof Kozlowski

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 2 Oct 2024 21:50:27 +0200

An of_node_put(bk_node) call was immediately used after a pointer check
for an of_get_property() call in this function implementation.
Thus call such a function only once instead directly before the check.

This issue was transformed by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/platforms/powermac/backlight.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/powermac/backlight.c b/arch/powerpc/platforms/powermac/backlight.c
index 12bc01353bd3..d3666595a62e 100644
--- a/arch/powerpc/platforms/powermac/backlight.c
+++ b/arch/powerpc/platforms/powermac/backlight.c
@@ -61,11 +61,9 @@ int pmac_has_backlight_type(const char *type)
 	if (bk_node) {
 		const char *prop = of_get_property(bk_node,
 				"backlight-control", NULL);
-		if (prop && strncmp(prop, type, strlen(type)) == 0) {
-			of_node_put(bk_node);
-			return 1;
-		}
 		of_node_put(bk_node);
+		if (prop && strncmp(prop, type, strlen(type)) == 0)
+			return 1;
 	}

 	return 0;
--
2.46.1



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

end of thread, other threads:[~2024-11-17 12:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-02 20:02 [PATCH] powermac: Call of_node_put(bk_node) only once in pmac_has_backlight_type() Markus Elfring
2024-10-02 20:43 ` Christophe Leroy
2024-10-03  5:56   ` Dan Carpenter
2024-10-03  6:53     ` Krzysztof Kozlowski
2024-10-07  7:15     ` Markus Elfring
2024-10-09  4:48   ` [PATCH] " Michael Ellerman
2024-10-11 16:18   ` [PATCH] powermac: Use of_property_match_string() " Markus Elfring
2024-10-11 16:25     ` Christophe Leroy
2024-10-13 13:41       ` Dan Carpenter
2024-11-17 12:09     ` Michael Ellerman

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