of: Fix a refcounting bug in __of_attach_node_sysfs()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 20 May 2020 12:04:14 +0000 (15:04 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 Jun 2020 15:48:59 +0000 (17:48 +0200)
commit837a7d741285d223e2f362946f037e4866c16800
treee458c0b8899812418beb38fdf1598b449a6aa7f1
parent52acdac16b0cae3513c330ace979f26b6ea28fee
of: Fix a refcounting bug in __of_attach_node_sysfs()

[ Upstream commit 8a325dd06f2358ea0888e4ff1c9ca4bc23bd53f3 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/of/kobj.c