]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
btrfs: fix extent_state leak in btrfs_lock_and_flush_ordered_range
authorNaohiro Aota <naohiro.aota@wdc.com>
Fri, 26 Jul 2019 07:47:05 +0000 (16:47 +0900)
committerDavid Sterba <dsterba@suse.com>
Fri, 26 Jul 2019 10:21:22 +0000 (12:21 +0200)
commita3b46b86ca76d7f9d487e6a0b594fd1984e0796e
treeefab271e267efffe207b474b9959af63152f683d
parent6e7ca09b583de4be6c27d9d4b06e8c5dd46a58fa
btrfs: fix extent_state leak in btrfs_lock_and_flush_ordered_range

btrfs_lock_and_flush_ordered_range() loads given "*cached_state" into
cachedp, which, in general, is NULL. Then, lock_extent_bits() updates
"cachedp", but it never goes backs to the caller. Thus the caller still
see its "cached_state" to be NULL and never free the state allocated
under btrfs_lock_and_flush_ordered_range(). As a result, we will
see massive state leak with e.g. fstests btrfs/005. Fix this bug by
properly handling the pointers.

Fixes: bd80d94efb83 ("btrfs: Always use a cached extent_state in btrfs_lock_and_flush_ordered_range")
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ordered-data.c