dlm: Fix kobject memleak
authorWang Hai <wanghai38@huawei.com>
Mon, 15 Jun 2020 03:25:33 +0000 (11:25 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Aug 2020 06:24:08 +0000 (08:24 +0200)
commit43542c18482696eb06e36e1309c2a099273d2a56
treefd08c7ed1000f05259eebd85f06d774ff45d530d
parent71de458ba27733b4d30ca71842f366ec215daffd
dlm: Fix kobject memleak

[ Upstream commit 0ffddafc3a3970ef7013696e7f36b3d378bc4c16 ]

Currently the error return path from kobject_init_and_add() is not
followed by a call to kobject_put() - which means we are leaking
the kobject.

Set do_unreg = 1 before kobject_init_and_add() to ensure that
kobject_put() can be called in its error patch.

Fixes: 901195ed7f4b ("Kobject: change GFS2 to use kobject_init_and_add")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
Signed-off-by: David Teigland <teigland@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/dlm/lockspace.c