linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: checking NULL or not in some functions
@ 2011-02-01  9:17 Tsutomu Itoh
  2011-02-02  5:07 ` Chris Samuel
  0 siblings, 1 reply; 3+ messages in thread
From: Tsutomu Itoh @ 2011-02-01  9:17 UTC (permalink / raw)
  To: linux-btrfs; +Cc: chris.mason

Because NULL is returned when the memory allocation fails,
it is checked whether it is NULL. 

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
---
 fs/btrfs/extent-tree.c |    2 ++
 fs/btrfs/extent_io.c   |    2 ++
 fs/btrfs/tree-log.c    |    6 ++++++
 3 files changed, 10 insertions(+)

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;



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: checking NULL or not in some functions
  2011-02-01  9:17 [PATCH] btrfs: checking NULL or not in some functions Tsutomu Itoh
@ 2011-02-02  5:07 ` Chris Samuel
  2011-02-02  5:33   ` Tsutomu Itoh
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Samuel @ 2011-02-02  5:07 UTC (permalink / raw)
  To: Tsutomu Itoh; +Cc: linux-btrfs, chris.mason

On 01/02/11 20:17, Tsutomu Itoh wrote:

> Because NULL is returned when the memory allocation fails,
> it is checked whether it is NULL. 

Were the callers modified to cope with these functions
returning -ENOMEM ?

cheers,
Chris (way behind with email)
-- 
 Chris Samuel  :  http://www.csamuel.org/  :  Melbourne, VIC

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: checking NULL or not in some functions
  2011-02-02  5:07 ` Chris Samuel
@ 2011-02-02  5:33   ` Tsutomu Itoh
  0 siblings, 0 replies; 3+ messages in thread
From: Tsutomu Itoh @ 2011-02-02  5:33 UTC (permalink / raw)
  To: Chris Samuel; +Cc: linux-btrfs, chris.mason

(2011/02/02 14:07), Chris Samuel wrote:
> On 01/02/11 20:17, Tsutomu Itoh wrote:
> 
>> Because NULL is returned when the memory allocation fails,
>> it is checked whether it is NULL. 
> 
> Were the callers modified to cope with these functions
> returning -ENOMEM ?

I have not modified it yet. Currently, there is a case that becomes
BUG_ON() or BUG().
I think that it is our future work to decrease BUG_ON().

Thanks,
Itoh

> 
> cheers,
> Chris (way behind with email)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-02-02  5:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-01  9:17 [PATCH] btrfs: checking NULL or not in some functions Tsutomu Itoh
2011-02-02  5:07 ` Chris Samuel
2011-02-02  5:33   ` Tsutomu Itoh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).