btrfs: Fix error handling in zlib
authorLi Zefan <lizf@cn.fujitsu.com>
Tue, 9 Nov 2010 00:27:27 +0000 (08:27 +0800)
committerLi Zefan <lizf@cn.fujitsu.com>
Wed, 22 Dec 2010 15:15:43 +0000 (23:15 +0800)
Return failure if alloc_page() fails to allocate memory,
and the upper code will just give up compression.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
fs/btrfs/zlib.c

index e5b8b22e07d69f28eaef8e1ed84705b3d9666fce..b01558661e3b80d69e83e70bc6b9c8d81929316c 100644 (file)
@@ -225,6 +225,10 @@ int btrfs_zlib_compress_pages(struct address_space *mapping,
        data_in = kmap(in_page);
 
        out_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
+       if (out_page == NULL) {
+               ret = -1;
+               goto out;
+       }
        cpage_out = kmap(out_page);
        pages[0] = out_page;
        nr_pages = 1;
@@ -263,6 +267,10 @@ int btrfs_zlib_compress_pages(struct address_space *mapping,
                                goto out;
                        }
                        out_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
+                       if (out_page == NULL) {
+                               ret = -1;
+                               goto out;
+                       }
                        cpage_out = kmap(out_page);
                        pages[nr_pages] = out_page;
                        nr_pages++;