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>
Fri, 21 Aug 2020 09:02:04 +0000 (11:02 +0200)
commitda8baaeeecbc972ae7d78cf7ecbf652529c5f639
treeb4a9dc148ed23b07afe2d579bbe2cc5f147c6ee3
parent54c0e11e368db34f7128cb44ec36020bacbb2594
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