From patchwork Sat Jun 19 18:13:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "JieJing.Zhang" X-Patchwork-Id: 106996 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o5JIDbs7012035 for ; Sat, 19 Jun 2010 18:13:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756605Ab0FSSNf (ORCPT ); Sat, 19 Jun 2010 14:13:35 -0400 Received: from mail-px0-f174.google.com ([209.85.212.174]:56713 "EHLO mail-px0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756489Ab0FSSNe (ORCPT ); Sat, 19 Jun 2010 14:13:34 -0400 Received: by pxi12 with SMTP id 12so857164pxi.19 for ; Sat, 19 Jun 2010 11:13:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=vXZbKgY8lEP+Jr9jcxEU7aNo4oDxyaajvOtlcVN63JM=; b=D9+wXaEMM010+lueYBB+vwI84ZbI3ChTsehnyuOMPH+h5DIheH4kVfP57ITRbEYrAI KwcOOp/FIoDgPWxLcIa/AyPLP5dr/olTKrCT7uyGSTffpPULlNN0Vf+59SzIeYSoKCp7 OXzH17MYzQFCat1CH8Sa/Kmf+OAIy2bBbKZ/c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=NUDzQUlPCe6ykqcxVA/CPBzm4690xROQK0zI/wfrv+HSDP9gPcSkqBp+fGVNc44x7K 7OqZdoDHLnrww77l9wkG0c0PtYjBkTzN5iGyKG1IIs2PU72Rqqe0zPXgWhZTr3JXOOVd pvJy+1V6BkUfb/rxzNLJbjkhyzI4wxZlAbk8g= Received: by 10.140.248.20 with SMTP id v20mr2185499rvh.235.1276971213909; Sat, 19 Jun 2010 11:13:33 -0700 (PDT) Received: from localhost.localdomain ([220.112.119.244]) by mx.google.com with ESMTPS id l29sm25773rvb.4.2010.06.19.11.13.30 (version=SSLv3 cipher=RC4-MD5); Sat, 19 Jun 2010 11:13:32 -0700 (PDT) From: "JieJing.Zhang" To: linux-btrfs@vger.kernel.org Cc: "JieJing.Zhang" Subject: [PATCH] Btrfs: handle kmalloc() failure in btrfs_file_aio_write() Date: Sun, 20 Jun 2010 02:13:14 +0800 Message-Id: <1276971194-24572-1-git-send-email-kzjeef@gmail.com> X-Mailer: git-send-email 1.7.0.4 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sat, 19 Jun 2010 18:13:37 +0000 (UTC) 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;