mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/1] nvmem: core: add missing of_node_put after calling of_parse_phandle
@ 2016-08-12  1:31 Peter Chen
  0 siblings, 0 replies; only message in thread
From: Peter Chen @ 2016-08-12  1:31 UTC (permalink / raw)
  To: srinivas.kandagatla, maxime.ripard; +Cc: linux-kernel, Peter Chen

of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
---
 drivers/nvmem/core.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 965911d..ea51472 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -619,6 +619,7 @@ struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *id)
 
 	struct device_node *nvmem_np;
 	int index;
+	struct nvmem_device *nvmem;
 
 	index = of_property_match_string(np, "nvmem-names", id);
 
@@ -626,7 +627,9 @@ struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *id)
 	if (!nvmem_np)
 		return ERR_PTR(-EINVAL);
 
-	return __nvmem_device_get(nvmem_np, NULL, NULL);
+	nvmem = __nvmem_device_get(nvmem_np, NULL, NULL);
+	of_node_put(nvmem_np);
+	return nvmem;
 }
 EXPORT_SYMBOL_GPL(of_nvmem_device_get);
 #endif
@@ -768,12 +771,16 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
 		return ERR_PTR(-EINVAL);
 
 	nvmem_np = of_get_next_parent(cell_np);
-	if (!nvmem_np)
+	if (!nvmem_np) {
+		of_node_put(cell_np);
 		return ERR_PTR(-EINVAL);
+	}
 
 	nvmem = __nvmem_device_get(nvmem_np, NULL, NULL);
-	if (IS_ERR(nvmem))
+	if (IS_ERR(nvmem)) {
+		of_node_put(cell_np);
 		return ERR_CAST(nvmem);
+	}
 
 	addr = of_get_property(cell_np, "reg", &len);
 	if (!addr || (len < 2 * sizeof(u32))) {
@@ -813,6 +820,7 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
 	}
 
 	nvmem_cell_add(cell);
+	of_node_put(cell_np);
 
 	return cell;
 
@@ -821,6 +829,7 @@ err_sanity:
 
 err_mem:
 	__nvmem_device_put(nvmem);
+	of_node_put(cell_np);
 
 	return ERR_PTR(rval);
 }
-- 
1.9.1

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-08-12  1:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-12  1:31 [PATCH 1/1] nvmem: core: add missing of_node_put after calling of_parse_phandle Peter Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome