summaryrefslogtreecommitdiff
path: root/fs/btrfs/Kconfig
diff options
context:
space:
mode:
authorTobin C. Harding <tobin@kernel.org>2019-05-13 06:39:12 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-06-11 13:23:52 +0300
commit5c9a20390c010548901d3f2469a9699c7e39b11c (patch)
tree04d99346985d69829fe7a5ecd737dbea0f305d6d /fs/btrfs/Kconfig
parent0fa88718cdc50d42a6f9191792d8eaede77bd293 (diff)
downloadlinux-5c9a20390c010548901d3f2469a9699c7e39b11c.tar.xz
btrfs: sysfs: don't leak memory when failing add fsid
commit e32773357d5cc271b1d23550b3ed026eb5c2a468 upstream. A failed call to kobject_init_and_add() must be followed by a call to kobject_put(). Currently in the error path when adding fs_devices we are missing this call. This could be fixed by calling btrfs_sysfs_remove_fsid() if btrfs_sysfs_add_fsid() returns an error or by adding a call to kobject_put() directly in btrfs_sysfs_add_fsid(). Here we choose the second option because it prevents the slightly unusual error path handling requirements of kobject from leaking out into btrfs functions. Add a call to kobject_put() in the error path of kobject_add_and_init(). This causes the release method to be called if kobject_init_and_add() fails. open_tree() is the function that calls btrfs_sysfs_add_fsid() and the error code in this function is already written with the assumption that the release method is called during the error path of open_tree() (as seen by the call to btrfs_sysfs_remove_fsid() under the fail_fsdev_sysfs label). 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>
Diffstat (limited to 'fs/btrfs/Kconfig')
0 files changed, 0 insertions, 0 deletions