Btrfs: handle kmalloc() failure in btrfs_file_aio_write()
diff mbox

Message ID 1276971194-24572-1-git-send-email-kzjeef@gmail.com
State New, archived
Headers show

Commit Message

JieJing.Zhang June 19, 2010, 6:13 p.m. UTC
None

Patch
diff mbox

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index e354c33..e0fcb6c 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -926,6 +926,10 @@  static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
 		     PAGE_CACHE_SIZE, PAGE_CACHE_SIZE /
 		     (sizeof(struct page *)));
 	pages = kmalloc(nrptrs * sizeof(struct page *), GFP_KERNEL);
+	if (!pages) {
+		ret = -ENOMEM;
+		goto out;
+	}
 
 	/* generic_write_checks can change our pos */
 	start_pos = pos;