From patchwork Tue Feb 1 09:17:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsutomu Itoh X-Patchwork-Id: 522171 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 p119IoZa029463 for ; Tue, 1 Feb 2011 09:18:50 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753192Ab1BAJSq (ORCPT ); Tue, 1 Feb 2011 04:18:46 -0500 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:41260 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752808Ab1BAJSo (ORCPT ); Tue, 1 Feb 2011 04:18:44 -0500 Received: from m3.gw.fujitsu.co.jp (unknown [10.0.50.73]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id 836FA3EE0AE for ; Tue, 1 Feb 2011 18:18:41 +0900 (JST) Received: from smail (m3 [127.0.0.1]) by outgoing.m3.gw.fujitsu.co.jp (Postfix) with ESMTP id 6831B45DE4D for ; Tue, 1 Feb 2011 18:18:41 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (s3.gw.fujitsu.co.jp [10.0.50.93]) by m3.gw.fujitsu.co.jp (Postfix) with ESMTP id 4FF4845DE57 for ; Tue, 1 Feb 2011 18:18:41 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id 373111DB803B for ; Tue, 1 Feb 2011 18:18:41 +0900 (JST) Received: from ml14.s.css.fujitsu.com (ml14.s.css.fujitsu.com [10.249.87.104]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id E4026E08004 for ; Tue, 1 Feb 2011 18:18:40 +0900 (JST) Received: from ml14.css.fujitsu.com (ml14 [127.0.0.1]) by ml14.s.css.fujitsu.com (Postfix) with ESMTP id B8B6A9F6D31; Tue, 1 Feb 2011 18:18:40 +0900 (JST) Received: from T-ITOH1.jp.fujitsu.com (unknown [10.124.101.86]) by ml14.s.css.fujitsu.com (Postfix) with SMTP id 6448C9F6C13; Tue, 1 Feb 2011 18:18:40 +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]); Tue, 01 Feb 2011 18:18:19 +0900 (JST) Message-Id: <201102010917.AA00006@T-ITOH1.jp.fujitsu.com> From: Tsutomu Itoh Date: Tue, 01 Feb 2011 18:17:35 +0900 To: linux-btrfs@vger.kernel.org Cc: chris.mason@oracle.com Subject: [PATCH] btrfs: checking NULL or not in some functions 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, 01 Feb 2011 09:18:51 +0000 (UTC) diff -urNp linux-2.6.38-rc2/fs/btrfs/extent-tree.c linux-2.6.38-rc2.new/fs/btrfs/extent-tree.c --- linux-2.6.38-rc2/fs/btrfs/extent-tree.c 2011-01-22 12:01:34.000000000 +0900 +++ linux-2.6.38-rc2.new/fs/btrfs/extent-tree.c 2011-02-01 14:47:14.000000000 +0900 @@ -6446,6 +6446,8 @@ static noinline int relocate_inode_pages int ret = 0; ra = kzalloc(sizeof(*ra), GFP_NOFS); + if (!ra) + return -ENOMEM; mutex_lock(&inode->i_mutex); first_index = start >> PAGE_CACHE_SHIFT; diff -urNp linux-2.6.38-rc2/fs/btrfs/extent_io.c linux-2.6.38-rc2.new/fs/btrfs/extent_io.c --- linux-2.6.38-rc2/fs/btrfs/extent_io.c 2011-01-22 12:01:34.000000000 +0900 +++ linux-2.6.38-rc2.new/fs/btrfs/extent_io.c 2011-02-01 14:23:41.000000000 +0900 @@ -1920,6 +1920,8 @@ static int submit_extent_page(int rw, st nr = bio_get_nr_vecs(bdev); bio = btrfs_bio_alloc(bdev, sector, nr, GFP_NOFS | __GFP_HIGH); + if (!bio) + return -ENOMEM; bio_add_page(bio, page, page_size, offset); bio->bi_end_io = end_io_func; diff -urNp linux-2.6.38-rc2/fs/btrfs/tree-log.c linux-2.6.38-rc2.new/fs/btrfs/tree-log.c --- linux-2.6.38-rc2/fs/btrfs/tree-log.c 2011-01-22 12:01:34.000000000 +0900 +++ linux-2.6.38-rc2.new/fs/btrfs/tree-log.c 2011-02-01 14:36:21.000000000 +0900 @@ -2725,7 +2725,13 @@ static int btrfs_log_inode(struct btrfs_ log = root->log_root; path = btrfs_alloc_path(); + if (!path) + return -ENOMEM; dst_path = btrfs_alloc_path(); + if (!dst_path) { + btrfs_free_path(path); + return -ENOMEM; + } min_key.objectid = inode->i_ino; min_key.type = BTRFS_INODE_ITEM_KEY;