[<prev] [next>] [day] [month] [year] [list]
Message-ID: <1470965474-30431-1-git-send-email-peter.chen@nxp.com>
Date: Fri, 12 Aug 2016 09:31:14 +0800
From: Peter Chen <peter.chen@....com>
To: <srinivas.kandagatla@...aro.org>,
<maxime.ripard@...e-electrons.com>
CC: <linux-kernel@...r.kernel.org>, Peter Chen <peter.chen@....com>
Subject: [PATCH 1/1] nvmem: core: add missing of_node_put after calling of_parse_phandle
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@...aro.org>
Cc: Maxime Ripard <maxime.ripard@...e-electrons.com>
Signed-off-by: Peter Chen <peter.chen@....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
Powered by blists - more mailing lists