Skip to content

Commit 4b72029

Browse files
author
Li Zefan
committed
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>
1 parent 8844355 commit 4b72029

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎fs/btrfs/zlib.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ int btrfs_zlib_compress_pages(struct address_space *mapping,
225225
data_in = kmap(in_page);
226226

227227
out_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
228+
if (out_page == NULL) {
229+
ret = -1;
230+
goto out;
231+
}
228232
cpage_out = kmap(out_page);
229233
pages[0] = out_page;
230234
nr_pages = 1;
@@ -263,6 +267,10 @@ int btrfs_zlib_compress_pages(struct address_space *mapping,
263267
goto out;
264268
}
265269
out_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
270+
if (out_page == NULL) {
271+
ret = -1;
272+
goto out;
273+
}
266274
cpage_out = kmap(out_page);
267275
pages[nr_pages] = out_page;
268276
nr_pages++;

0 commit comments

Comments
 (0)