summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2010-11-09 01:27:27 +0100
committerLi Zefan <lizf@cn.fujitsu.com>2010-12-22 16:15:43 +0100
commit4b72029dc3fd6ba7dc45ccd1cf0aa0ebfa209bd3 (patch)
tree116285c40ed2fa30e91d164e2e16e0d82ae450f9
parentbtrfs: Fix bugs in zlib workspace (diff)
downloadlinux-4b72029dc3fd6ba7dc45ccd1cf0aa0ebfa209bd3.tar.xz
linux-4b72029dc3fd6ba7dc45ccd1cf0aa0ebfa209bd3.zip
btrfs: Fix error handling in zlib
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>
-rw-r--r--fs/btrfs/zlib.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c
index e5b8b22e07d6..b01558661e3b 100644
--- a/fs/btrfs/zlib.c
+++ b/fs/btrfs/zlib.c
@@ -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++;