of: Fix a refcounting bug in __of_attach_node_sysfs()
[ Upstream commit8a325dd06f
] 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:5b2c2f5a0e
("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
f9db526da5
commit
cde05d643e
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue