]> Git Repo - linux.git/commitdiff
btrfs: fix page leaks after failure to lock page for delalloc
authorRobbie Ko <[email protected]>
Mon, 20 Jul 2020 01:42:09 +0000 (09:42 +0800)
committerDavid Sterba <[email protected]>
Tue, 21 Jul 2020 20:08:53 +0000 (22:08 +0200)
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: [email protected] # 4.14+
Reviewed-by: Filipe Manana <[email protected]>
Reviewed-by: Nikolay Borisov <[email protected]>
Signed-off-by: Robbie Ko <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
fs/btrfs/extent_io.c

index 95313bb7fe40d2cdb8f79e76fcfdf696cdc9c83e..72c836b54efc0d687b64fd8e6165a331002d6756 100644 (file)
@@ -1999,7 +1999,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;
                                }
This page took 0.06732 seconds and 4 git commands to generate.