* [PATCH] nvmem: core: fix missing of_node_put() in of_nvmem_device_get()
@ 2020-09-15 21:48 Vadym Kochan
2020-09-16 8:46 ` Srinivas Kandagatla
0 siblings, 1 reply; 2+ messages in thread
From: Vadym Kochan @ 2020-09-15 21:48 UTC (permalink / raw)
To: Srinivas Kandagatla, Greg Kroah-Hartman, linux-kernel; +Cc: Vadym Kochan
of_parse_phandle() returns device_node with incremented ref count
which needs to be decremented by of_node_put() when device_node
is not used.
Fixes: e2a5402ec7c6 ("nvmem: Add nvmem_device based consumer apis.")
Signed-off-by: Vadym Kochan <vadym.kochan@plvision.eu>
---
drivers/nvmem/core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 6cd3edb2eaf6..204a515d8bc5 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -835,6 +835,7 @@ struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *id)
{
struct device_node *nvmem_np;
+ struct nvmem_device *nvmem;
int index = 0;
if (id)
@@ -844,7 +845,9 @@ struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *id)
if (!nvmem_np)
return ERR_PTR(-ENOENT);
- return __nvmem_device_get(nvmem_np, device_match_of_node);
+ nvmem = __nvmem_device_get(nvmem_np, device_match_of_node);
+ of_node_put(nvmem_np);
+ return nvmem;
}
EXPORT_SYMBOL_GPL(of_nvmem_device_get);
#endif
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] nvmem: core: fix missing of_node_put() in of_nvmem_device_get()
2020-09-15 21:48 [PATCH] nvmem: core: fix missing of_node_put() in of_nvmem_device_get() Vadym Kochan
@ 2020-09-16 8:46 ` Srinivas Kandagatla
0 siblings, 0 replies; 2+ messages in thread
From: Srinivas Kandagatla @ 2020-09-16 8:46 UTC (permalink / raw)
To: Vadym Kochan, Greg Kroah-Hartman, linux-kernel
On 15/09/2020 22:48, Vadym Kochan wrote:
> of_parse_phandle() returns device_node with incremented ref count
> which needs to be decremented by of_node_put() when device_node
> is not used.
>
> Fixes: e2a5402ec7c6 ("nvmem: Add nvmem_device based consumer apis.")
> Signed-off-by: Vadym Kochan <vadym.kochan@plvision.eu>
> ---
> drivers/nvmem/core.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
Applied thanks,
--srini
>
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index 6cd3edb2eaf6..204a515d8bc5 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -835,6 +835,7 @@ struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *id)
> {
>
> struct device_node *nvmem_np;
> + struct nvmem_device *nvmem;
> int index = 0;
>
> if (id)
> @@ -844,7 +845,9 @@ struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *id)
> if (!nvmem_np)
> return ERR_PTR(-ENOENT);
>
> - return __nvmem_device_get(nvmem_np, device_match_of_node);
> + nvmem = __nvmem_device_get(nvmem_np, device_match_of_node);
> + of_node_put(nvmem_np);
> + return nvmem;
> }
> EXPORT_SYMBOL_GPL(of_nvmem_device_get);
> #endif
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-09-16 8:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-15 21:48 [PATCH] nvmem: core: fix missing of_node_put() in of_nvmem_device_get() Vadym Kochan
2020-09-16 8:46 ` Srinivas Kandagatla
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).