]> git.ipfire.org Git - people/arne_f/kernel.git/commitdiff
btrfs: fix page leaks after failure to lock page for delalloc
authorRobbie Ko <robbieko@synology.com>
Mon, 20 Jul 2020 01:42:09 +0000 (09:42 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Jul 2020 05:42:53 +0000 (07:42 +0200)
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>
fs/btrfs/extent_io.c

index c55c2ae335eae1f48ae7a54343cab5f80b6158b0..6d2bfbb63d9bae4216dc6e9d6a91ab52f50b72c9 100644 (file)
@@ -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;
                                }