]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
btrfs: sysfs: Fix error path kobject memory leak
authorTobin C. Harding <tobin@kernel.org>
Mon, 13 May 2019 03:39:11 +0000 (13:39 +1000)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
commit3520c2039135dddae3b7ddce1098891c586086e5
tree95fb0939a96061157fa94eae6dfd583431dc2f34
parent5fae68187b829f702910fba78869bc23b3b6358f
btrfs: sysfs: Fix error path kobject memory leak

BugLink: https://bugs.launchpad.net/bugs/1838700
commit 450ff8348808a89cc27436771aa05c2b90c0eef1 upstream.

If a call to kobject_init_and_add() fails we must call kobject_put()
otherwise we leak memory.

Calling kobject_put() when kobject_init_and_add() fails drops the
refcount back to 0 and calls the ktype release method (which in turn
calls the percpu destroy and kfree).

Add call to kobject_put() in the error path of call to
kobject_init_and_add().

Cc: stable@vger.kernel.org # v4.4+
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tobin C. Harding <tobin@kernel.org>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
fs/btrfs/extent-tree.c