diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2020-05-20 14:04:14 +0200 |
---|---|---|
committer | Rob Herring <robh@kernel.org> | 2020-05-28 03:30:25 +0200 |
commit | 8a325dd06f2358ea0888e4ff1c9ca4bc23bd53f3 (patch) | |
tree | 43b15e49cc02ece48eb1f19eb864e8faba9d4a56 /drivers/of/kobj.c | |
parent | mfd: lochnagar: Move binding over to dtschema (diff) | |
download | linux-8a325dd06f2358ea0888e4ff1c9ca4bc23bd53f3.tar.xz linux-8a325dd06f2358ea0888e4ff1c9ca4bc23bd53f3.zip |
of: Fix a refcounting bug in __of_attach_node_sysfs()
The problem in this code is that if kobject_add() fails, then it should
call of_node_put(np) to drop the reference count. I've actually moved
the of_node_get(np) later in the function to avoid needing to do clean
up.
Fixes: 5b2c2f5a0ea3 ("of: overlay: add missing of_node_get() in __of_attach_node_sysfs")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'drivers/of/kobj.c')
-rw-r--r-- | drivers/of/kobj.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/of/kobj.c b/drivers/of/kobj.c index c72eef988041..a32e60b024b8 100644 --- a/drivers/of/kobj.c +++ b/drivers/of/kobj.c @@ -134,8 +134,6 @@ 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) @@ -144,6 +142,7 @@ int __of_attach_node_sysfs(struct device_node *np) for_each_property_of_node(np, pp) __of_add_property_sysfs(np, pp); + of_node_get(np); return 0; } |