]> git.baikalelectronics.ru Git - kernel.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)
commit7bc4614ac94246a8478cf794fdf964e2b721ac1c
treeefab271e267efffe207b474b9959af63152f683d
parent68c7bf7a313befc93864df902317a8c3963ffa55
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: 2b5b5dfbd6d8 ("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