diff options
author | Frank Rowand <frank.rowand@sony.com> | 2018-10-05 06:26:05 +0300 |
---|---|---|
committer | Frank Rowand <frank.rowand@sony.com> | 2018-11-09 09:10:53 +0300 |
commit | 5b2c2f5a0ea3a43e0dee78059e34c7cb54136dcc (patch) | |
tree | 8d1e20deb84d02045599fc0e717a42bfd2a98262 /drivers/of/kobj.c | |
parent | 7c528e457d53c75107d5aa56892316d265c778de (diff) | |
download | linux-5b2c2f5a0ea3a43e0dee78059e34c7cb54136dcc.tar.xz |
of: overlay: add missing of_node_get() in __of_attach_node_sysfs
There is a matching of_node_put() in __of_detach_node_sysfs()
Remove misleading comment from function header comment for
of_detach_node().
This patch may result in memory leaks from code that directly calls
the dynamic node add and delete functions directly instead of
using changesets.
This commit should result in powerpc systems that dynamically
allocate a node, then later deallocate the node to have a
memory leak when the node is deallocated.
The next commit will fix the leak.
Tested-by: Alan Tull <atull@kernel.org>
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Signed-off-by: Frank Rowand <frank.rowand@sony.com>
Diffstat (limited to 'drivers/of/kobj.c')
-rw-r--r-- | drivers/of/kobj.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/of/kobj.c b/drivers/of/kobj.c index 7a0a18980b98..c72eef988041 100644 --- a/drivers/of/kobj.c +++ b/drivers/of/kobj.c @@ -133,6 +133,9 @@ int __of_attach_node_sysfs(struct device_node *np) } if (!name) return -ENOMEM; + + of_node_get(np); + rc = kobject_add(&np->kobj, parent, "%s", name); kfree(name); if (rc) @@ -159,6 +162,5 @@ void __of_detach_node_sysfs(struct device_node *np) kobject_del(&np->kobj); } - /* finally remove the kobj_init ref */ of_node_put(np); } |