From: Peter Chen <peter.chen@nxp.com>
To: <srinivas.kandagatla@linaro.org>, <maxime.ripard@free-electrons.com>
Cc: <linux-kernel@vger.kernel.org>, Peter Chen <peter.chen@nxp.com>
Subject: [PATCH 1/1] nvmem: core: add missing of_node_put after calling of_parse_phandle
Date: Fri, 12 Aug 2016 09:31:14 +0800 [thread overview]
Message-ID: <1470965474-30431-1-git-send-email-peter.chen@nxp.com> (raw)
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
reply other threads:[~2016-08-12 1:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1470965474-30431-1-git-send-email-peter.chen@nxp.com \
--to=peter.chen@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maxime.ripard@free-electrons.com \
--cc=srinivas.kandagatla@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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