From patchwork Tue Apr 19 05:27:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsutomu Itoh X-Patchwork-Id: 716971 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3J5Srsd030385 for ; Tue, 19 Apr 2011 05:28:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752652Ab1DSF2v (ORCPT ); Tue, 19 Apr 2011 01:28:51 -0400 Received: from fgwmail5.fujitsu.co.jp ([192.51.44.35]:44264 "EHLO fgwmail5.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752631Ab1DSF2u (ORCPT ); Tue, 19 Apr 2011 01:28:50 -0400 Received: from m4.gw.fujitsu.co.jp (unknown [10.0.50.74]) by fgwmail5.fujitsu.co.jp (Postfix) with ESMTP id 6309A3EE0C7 for ; Tue, 19 Apr 2011 14:28:49 +0900 (JST) Received: from smail (m4 [127.0.0.1]) by outgoing.m4.gw.fujitsu.co.jp (Postfix) with ESMTP id 4B74045DE4E for ; Tue, 19 Apr 2011 14:28:49 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (s4.gw.fujitsu.co.jp [10.0.50.94]) by m4.gw.fujitsu.co.jp (Postfix) with ESMTP id 25CE945DE50 for ; Tue, 19 Apr 2011 14:28:49 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id 136EFE78003 for ; Tue, 19 Apr 2011 14:28:49 +0900 (JST) Received: from m107.s.css.fujitsu.com (m107.s.css.fujitsu.com [10.240.81.147]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id D58651DB8037 for ; Tue, 19 Apr 2011 14:28:48 +0900 (JST) Received: from m107.css.fujitsu.com (m107 [127.0.0.1]) by m107.s.css.fujitsu.com (Postfix) with ESMTP id A44DB670008; Tue, 19 Apr 2011 14:28:48 +0900 (JST) Received: from T-ITOH1.jp.fujitsu.com (unknown [10.124.101.84]) by m107.s.css.fujitsu.com (Postfix) with SMTP id 484EA670003; Tue, 19 Apr 2011 14:28:48 +0900 (JST) X-SecurityPolicyCheck-FJ: OK by FujitsuOutboundMailChecker v1.4.0 Received: from T-ITOH1[10.124.101.84] by T-ITOH1 (FujitsuOutboundMailChecker v1.4.0/9992[10.124.101.84]); Tue, 19 Apr 2011 14:27:33 +0900 (JST) Message-Id: <201104190527.AA00014@T-ITOH1.jp.fujitsu.com> From: Tsutomu Itoh Date: Tue, 19 Apr 2011 14:27:08 +0900 To: linux-btrfs@vger.kernel.org Cc: chris.mason@oracle.com Subject: [PATCH] Btrfs: check return value of kmalloc() MIME-Version: 1.0 X-Mailer: AL-Mail32 Version 1.13 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.6 (demeter1.kernel.org [140.211.167.41]); Tue, 19 Apr 2011 05:28:54 +0000 (UTC) The check on the return value of kmalloc() in inode.c is added. Signed-off-by: Tsutomu Itoh --- fs/btrfs/inode.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index a4157cf..c718d27 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -953,6 +953,7 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page, 1, 0, NULL, GFP_NOFS); while (start < end) { async_cow = kmalloc(sizeof(*async_cow), GFP_NOFS); + BUG_ON(!async_cow); async_cow->inode = inode; async_cow->root = root; async_cow->locked_page = locked_page; @@ -5001,6 +5002,8 @@ static noinline int uncompress_inline(struct btrfs_path *path, inline_size = btrfs_file_extent_inline_item_len(leaf, btrfs_item_nr(leaf, path->slots[0])); tmp = kmalloc(inline_size, GFP_NOFS); + if (!tmp) + return -ENOMEM; ptr = btrfs_file_extent_inline_start(item); read_extent_buffer(leaf, tmp, ptr, inline_size);