All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] memory/tegra: Add missing of_node_get() in tegra_emc_find_node_by_ram_code
@ 2022-06-22  4:28 Liang He
  2022-06-22  6:50 ` Krzysztof Kozlowski
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Liang He @ 2022-06-22  4:28 UTC (permalink / raw)
  To: krzysztof.kozlowski, thierry.reding, jonathanh
  Cc: windhl, linux-kernel, linux-tegra

of_find_node_by_name() will decrease the refcount of its first arg and
we need to add a of_node_put() to keep refcount balance.

Besides, during the 'for' loop execution, the refcount of 'np' will be
automatically increased and decreased. There is no need to call
of_node_put() again.

Signed-off-by: Liang He <windhl@126.com>
---
 drivers/memory/tegra/tegra20-emc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/memory/tegra/tegra20-emc.c b/drivers/memory/tegra/tegra20-emc.c
index 25ba3c5e4ad6..e43a5f8e188e 100644
--- a/drivers/memory/tegra/tegra20-emc.c
+++ b/drivers/memory/tegra/tegra20-emc.c
@@ -477,6 +477,7 @@ tegra_emc_find_node_by_ram_code(struct tegra_emc *emc)
 
 	ram_code = tegra_read_ram_code();
 
+	of_get_node(dev->of_node);
 	for (np = of_find_node_by_name(dev->of_node, "emc-tables"); np;
 	     np = of_find_node_by_name(np, "emc-tables")) {
 		err = of_property_read_u32(np, "nvidia,ram-code", &value);
@@ -484,6 +485,7 @@ tegra_emc_find_node_by_ram_code(struct tegra_emc *emc)
 			struct device_node *lpddr2_np;
 			bool cfg_mismatches = false;
 
+			of_node_get(np);
 			lpddr2_np = of_find_node_by_name(np, "lpddr2");
 			if (lpddr2_np) {
 				const struct lpddr2_info *info;
@@ -521,7 +523,6 @@ tegra_emc_find_node_by_ram_code(struct tegra_emc *emc)
 			}
 
 			if (cfg_mismatches) {
-				of_node_put(np);
 				continue;
 			}
 		}
-- 
2.25.1


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

end of thread, other threads:[~2022-06-22  9:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-22  4:28 [PATCH] memory/tegra: Add missing of_node_get() in tegra_emc_find_node_by_ram_code Liang He
2022-06-22  6:50 ` Krzysztof Kozlowski
2022-06-22  6:56   ` Liang He
2022-06-22  8:35 ` kernel test robot
2022-06-22  8:41 ` Krzysztof Kozlowski
2022-06-22  8:49   ` Liang He
2022-06-22  9:08     ` Krzysztof Kozlowski
2022-06-22  9:09       ` Krzysztof Kozlowski
2022-06-22  9:20       ` Liang He

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.