summaryrefslogtreecommitdiff
path: root/fs/btrfs
diff options
context:
space:
mode:
authorRobbie Ko <robbieko@synology.com>2020-07-20 04:42:09 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-07-29 08:42:53 +0300
commitbb8911560bc889734f5165e58062d80d11a0a0f9 (patch)
treedfd5fbcf8c312e54de48f0f19ed187dfce68740b /fs/btrfs
parenta6979ac2c3f7d0e0cad140ecb7831e81456e82fa (diff)
downloadlinux-bb8911560bc889734f5165e58062d80d11a0a0f9.tar.xz
btrfs: fix page leaks after failure to lock page for delalloc
commit 5909ca110b29aa16b23b52b8de8d3bb1035fd738 upstream. When locking pages for delalloc, we check if it's dirty and mapping still matches. If it does not match, we need to return -EAGAIN and release all pages. Only the current page was put though, iterate over all the remaining pages too. CC: stable@vger.kernel.org # 4.14+ Reviewed-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: Robbie Ko <robbieko@synology.com> 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')
-rw-r--r--fs/btrfs/extent_io.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index c55c2ae335ea..6d2bfbb63d9b 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1721,7 +1721,8 @@ static int __process_pages_contig(struct address_space *mapping,
if (!PageDirty(pages[i]) ||
pages[i]->mapping != mapping) {
unlock_page(pages[i]);
- put_page(pages[i]);
+ for (; i < ret; i++)
+ put_page(pages[i]);
err = -EAGAIN;
goto out;
}