linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: fix uninitialized return value
@ 2011-06-13 15:18 David Sterba
  2011-06-14  2:58 ` Li Zefan
  0 siblings, 1 reply; 2+ messages in thread
From: David Sterba @ 2011-06-13 15:18 UTC (permalink / raw)
  To: linux-btrfs; +Cc: chris.mason, David Sterba

When allocation fails in btrfs_read_fs_root_no_name, ret is not set
although it is returned, holding a garbage value.

Signed-off-by: David Sterba <dsterba@suse.cz>
---
 fs/btrfs/disk-io.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 9f68c68..7e48b01 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1300,12 +1300,12 @@ again:
 		return root;
 
 	root->free_ino_ctl = kzalloc(sizeof(*root->free_ino_ctl), GFP_NOFS);
-	if (!root->free_ino_ctl)
-		goto fail;
 	root->free_ino_pinned = kzalloc(sizeof(*root->free_ino_pinned),
 					GFP_NOFS);
-	if (!root->free_ino_pinned)
+	if (!root->free_ino_pinned || !root->free_ino_ctl) {
+		ret = -ENOMEM;
 		goto fail;
+	}
 
 	btrfs_init_free_ino_ctl(root);
 	mutex_init(&root->fs_commit_mutex);
-- 
1.7.5.2.353.g5df3e


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

* Re: [PATCH] btrfs: fix uninitialized return value
  2011-06-13 15:18 [PATCH] btrfs: fix uninitialized return value David Sterba
@ 2011-06-14  2:58 ` Li Zefan
  0 siblings, 0 replies; 2+ messages in thread
From: Li Zefan @ 2011-06-14  2:58 UTC (permalink / raw)
  To: David Sterba; +Cc: linux-btrfs, chris.mason

23:18, David Sterba wrote:
> When allocation fails in btrfs_read_fs_root_no_name, ret is not set
> although it is returned, holding a garbage value.
> 
> Signed-off-by: David Sterba <dsterba@suse.cz>

Thanks! My gcc doesn't warn on this..

Reviewed-by: Li Zefan <lizf@cn.fujitsu.com>


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

end of thread, other threads:[~2011-06-14  2:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-13 15:18 [PATCH] btrfs: fix uninitialized return value David Sterba
2011-06-14  2:58 ` Li Zefan

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).