From patchwork Wed Jan 5 02:32:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsutomu Itoh X-Patchwork-Id: 452681 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 p052XHiP013885 for ; Wed, 5 Jan 2011 02:33:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751047Ab1AECdH (ORCPT ); Tue, 4 Jan 2011 21:33:07 -0500 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:38965 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750875Ab1AECdG (ORCPT ); Tue, 4 Jan 2011 21:33:06 -0500 Received: from m2.gw.fujitsu.co.jp (unknown [10.0.50.72]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id 42B6C3EE0BC for ; Wed, 5 Jan 2011 11:33:03 +0900 (JST) Received: from smail (m2 [127.0.0.1]) by outgoing.m2.gw.fujitsu.co.jp (Postfix) with ESMTP id EDB9445DE69 for ; Wed, 5 Jan 2011 11:33:02 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (s2.gw.fujitsu.co.jp [10.0.50.92]) by m2.gw.fujitsu.co.jp (Postfix) with ESMTP id A09C645DE67 for ; Wed, 5 Jan 2011 11:33:02 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 85E57E08004 for ; Wed, 5 Jan 2011 11:33:02 +0900 (JST) Received: from m108.s.css.fujitsu.com (m108.s.css.fujitsu.com [10.249.87.108]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 52D0BE08001 for ; Wed, 5 Jan 2011 11:33:02 +0900 (JST) Received: from m108.css.fujitsu.com (m108 [127.0.0.1]) by m108.s.css.fujitsu.com (Postfix) with ESMTP id 2610D428052; Wed, 5 Jan 2011 11:33:02 +0900 (JST) Received: from T-ITOH1.jp.fujitsu.com (unknown [10.124.101.86]) by m108.s.css.fujitsu.com (Postfix) with SMTP id BF422428059; Wed, 5 Jan 2011 11:33:01 +0900 (JST) X-SecurityPolicyCheck-FJ: OK by FujitsuOutboundMailChecker v1.4.0 Received: from T-ITOH1[10.124.101.86] by T-ITOH1 (FujitsuOutboundMailChecker v1.4.0/9992[10.124.101.86]); Wed, 05 Jan 2011 11:32:58 +0900 (JST) Message-Id: <201101050232.AA00003@T-ITOH1.jp.fujitsu.com> From: Tsutomu Itoh Date: Wed, 05 Jan 2011 11:32:22 +0900 To: linux-btrfs@vger.kernel.org Cc: chris.mason@oracle.com Subject: [PATCH] btrfs: check NULL or not 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.3 (demeter1.kernel.org [140.211.167.41]); Wed, 05 Jan 2011 02:33:18 +0000 (UTC) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 9ac1715..f68c6ff 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -2514,6 +2514,9 @@ static int push_leaf_right(struct btrfs_trans_handle *trans, struct btrfs_root btrfs_assert_tree_locked(path->nodes[1]); right = read_node_slot(root, upper, slot + 1); + if (right == NULL) + return 1; + btrfs_tree_lock(right); btrfs_set_lock_blocking(right); @@ -2764,6 +2767,9 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root btrfs_assert_tree_locked(path->nodes[1]); left = read_node_slot(root, path->nodes[1], slot - 1); + if (left == NULL) + return 1; + btrfs_tree_lock(left); btrfs_set_lock_blocking(left); diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index a5d2249..5ede105 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -353,6 +353,10 @@ static int csum_dirty_buffer(struct btrfs_root *root, struct page *page) WARN_ON(len == 0); eb = alloc_extent_buffer(tree, start, len, page, GFP_NOFS); + if (eb == NULL) { + WARN_ON(1); + goto out; + } ret = btree_read_extent_buffer_pages(root, eb, start + PAGE_CACHE_SIZE, btrfs_header_generation(eb)); BUG_ON(ret); @@ -427,6 +431,10 @@ static int btree_readpage_end_io_hook(struct page *page, u64 start, u64 end, WARN_ON(len == 0); eb = alloc_extent_buffer(tree, start, len, page, GFP_NOFS); + if (eb == NULL) { + ret = -EIO; + goto out; + } found_start = btrfs_header_bytenr(eb); if (found_start != start) { diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 5e7a94d..d05c5d2 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3072,6 +3072,8 @@ static struct extent_buffer *__alloc_extent_buffer(struct extent_io_tree *tree, #endif eb = kmem_cache_zalloc(extent_buffer_cache, mask); + if (eb == NULL) + return NULL; eb->start = start; eb->len = len; spin_lock_init(&eb->lock);