Skip to content

Commit b1c194d

Browse files
vkochan-plvgregkh
authored andcommitted
nvmem: core: fix missing of_node_put() in of_nvmem_device_get()
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: e2a5402 ("nvmem: Add nvmem_device based consumer apis.") Signed-off-by: Vadym Kochan <vadym.kochan@plvision.eu> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20200917134437.16637-5-srinivas.kandagatla@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1eb51d6 commit b1c194d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/nvmem/core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *id)
835835
{
836836

837837
struct device_node *nvmem_np;
838+
struct nvmem_device *nvmem;
838839
int index = 0;
839840

840841
if (id)
@@ -844,7 +845,9 @@ struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *id)
844845
if (!nvmem_np)
845846
return ERR_PTR(-ENOENT);
846847

847-
return __nvmem_device_get(nvmem_np, device_match_of_node);
848+
nvmem = __nvmem_device_get(nvmem_np, device_match_of_node);
849+
of_node_put(nvmem_np);
850+
return nvmem;
848851
}
849852
EXPORT_SYMBOL_GPL(of_nvmem_device_get);
850853
#endif

0 commit comments

Comments
 (0)