From patchwork Thu Jul 29 19:15:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kulikov Vasiliy X-Patchwork-Id: 115289 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6TJHA2e005830 for ; Thu, 29 Jul 2010 19:17:10 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755624Ab0G2TRH (ORCPT ); Thu, 29 Jul 2010 15:17:07 -0400 Received: from mail-ey0-f174.google.com ([209.85.215.174]:53656 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754739Ab0G2TRG (ORCPT ); Thu, 29 Jul 2010 15:17:06 -0400 Received: by eya25 with SMTP id 25so374584eya.19 for ; Thu, 29 Jul 2010 12:17:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=XMr12C+9SsR9VYaw8mAVLaYd22hgvMiNCEQnO8g/k18=; b=Dv7Wkq5n9WTiNYaOXETqS9fWHLrAggydF6heGEq0ROC7z2TnHdhTk8BRA3G4nVs762 zN+49ER4e7KhYKhblofNiFhGp3JAcbScHjq2VcRNYpjgkxUjQhbKHu6/lLiZS4vfU7pd +CLE3oh6Oys3WLtTm4195B0t00mlJuDtRJqlI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=M4XseceByY0TTnzKAGXent2QEBQXHcWEXPQTK6mNA8R1yVBODOg4CC1t0ibWd7OC/9 9ah3NZalYB318xm1/y1Y5AjHnPxuZjpU8LYDL0l8w/lROdmhDxFN+r1gxSAzWilIZAen 2/Hq84NPf7QeHj94rga1qXWgLxqYIIQIV6ZQg= Received: by 10.213.27.143 with SMTP id i15mr7069799ebc.38.1280431023211; Thu, 29 Jul 2010 12:17:03 -0700 (PDT) Received: from localhost ([213.87.88.54]) by mx.google.com with ESMTPS id a48sm1734661eei.19.2010.07.29.12.16.42 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 29 Jul 2010 12:17:02 -0700 (PDT) Date: Thu, 29 Jul 2010 23:15:57 +0400 From: Vasiliy Kulikov To: kernel-janitors@vger.kernel.org, linux-btrfs@vger.kernel.org Subject: [Bug] check return of kmalloc() Message-ID: <20100729191557.GA9784@albatros> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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]); Thu, 29 Jul 2010 19:17:11 +0000 (UTC) --- ./fs/btrfs/compression.c 2010-07-06 16:45:48.000000000 +0400 +++ /tmp/cocci-output-7773-0df3b6-compression.c 2010-07-28 18:43:07.000000000 +0400 @@ -350,7 +350,6 @@ int btrfs_submit_compressed_write(struct int ret; WARN_ON(start & ((u64)PAGE_CACHE_SIZE - 1)); - cb = kmalloc(compressed_bio_size(root, compressed_len), GFP_NOFS); atomic_set(&cb->pending_bios, 0); cb->errors = 0; cb->inode = inode; @@ -587,7 +586,6 @@ int btrfs_submit_compressed_read(struct read_unlock(&em_tree->lock); compressed_len = em->block_len; - cb = kmalloc(compressed_bio_size(root, compressed_len), GFP_NOFS); atomic_set(&cb->pending_bios, 0); cb->errors = 0; cb->inode = inode; --- ./fs/btrfs/tree-log.c 2010-07-06 16:45:48.000000000 +0400 +++ /tmp/cocci-output-7783-8f7d1b-tree-log.c 2010-07-28 18:43:08.000000000 +0400 @@ -336,8 +336,6 @@ static noinline int overwrite_item(struc btrfs_release_path(root, path); return 0; } - dst_copy = kmalloc(item_size, GFP_NOFS); - src_copy = kmalloc(item_size, GFP_NOFS); read_extent_buffer(eb, src_copy, src_ptr, item_size); @@ -664,7 +662,6 @@ static noinline int drop_one_dir_item(st btrfs_dir_item_key_to_cpu(leaf, di, &location); name_len = btrfs_dir_name_len(leaf, di); - name = kmalloc(name_len, GFP_NOFS); read_extent_buffer(leaf, name, (unsigned long)(di + 1), name_len); btrfs_release_path(root, path); @@ -819,7 +816,6 @@ again: ref = (struct btrfs_inode_ref *)ref_ptr; namelen = btrfs_inode_ref_name_len(eb, ref); - name = kmalloc(namelen, GFP_NOFS); BUG_ON(!name); read_extent_buffer(eb, name, (unsigned long)(ref + 1), namelen); @@ -1182,7 +1177,6 @@ static noinline int replay_one_name(stru BUG_ON(!dir); name_len = btrfs_dir_name_len(eb, di); - name = kmalloc(name_len, GFP_NOFS); log_type = btrfs_dir_type(eb, di); read_extent_buffer(eb, name, (unsigned long)(di + 1), name_len); @@ -2605,8 +2599,6 @@ static noinline int copy_items(struct bt INIT_LIST_HEAD(&ordered_sums); - ins_data = kmalloc(nr * sizeof(struct btrfs_key) + - nr * sizeof(u32), GFP_NOFS); ins_sizes = (u32 *)ins_data; ins_keys = (struct btrfs_key *)(ins_data + nr * sizeof(u32)); --- ./fs/btrfs/file.c 2010-07-09 15:55:34.000000000 +0400 +++ /tmp/cocci-output-7826-b84666-file.c 2010-07-28 18:43:13.000000000 +0400 @@ -925,7 +925,6 @@ static ssize_t btrfs_file_aio_write(stru nrptrs = min((iov_iter_count(&i) + PAGE_CACHE_SIZE - 1) / PAGE_CACHE_SIZE, PAGE_CACHE_SIZE / (sizeof(struct page *))); - pages = kmalloc(nrptrs * sizeof(struct page *), GFP_KERNEL); /* generic_write_checks can change our pos */ start_pos = pos; --- ./fs/btrfs/inode.c 2010-07-28 08:11:33.000000000 +0400 +++ /tmp/cocci-output-7824-c1d367-inode.c 2010-07-28 18:43:15.000000000 +0400 @@ -284,7 +284,6 @@ static noinline int add_async_extent(str { struct async_extent *async_extent; - async_extent = kmalloc(sizeof(*async_extent), GFP_NOFS); async_extent->start = start; async_extent->ram_size = ram_size; async_extent->compressed_size = compressed_size; @@ -940,7 +939,6 @@ static int cow_file_range_async(struct i clear_extent_bit(&BTRFS_I(inode)->io_tree, start, end, EXTENT_LOCKED, 1, 0, NULL, GFP_NOFS); while (start < end) { - async_cow = kmalloc(sizeof(*async_cow), GFP_NOFS); async_cow->inode = inode; async_cow->root = root; async_cow->locked_page = locked_page; @@ -4891,7 +4888,6 @@ static noinline int uncompress_inline(st max_size = btrfs_file_extent_ram_bytes(leaf, item); inline_size = btrfs_file_extent_inline_item_len(leaf, btrfs_item_nr(leaf, path->slots[0])); - tmp = kmalloc(inline_size, GFP_NOFS); ptr = btrfs_file_extent_inline_start(item); read_extent_buffer(leaf, tmp, ptr, inline_size);