public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Btrfs: fix bug in open_ctree()
@ 2009-01-17 15:03 Qinghuang Feng
  2009-01-17 21:29 ` Chris Mason
  0 siblings, 1 reply; 2+ messages in thread
From: Qinghuang Feng @ 2009-01-17 15:03 UTC (permalink / raw)
  To: chris.mason; +Cc: linux-kernel, linux-btrfs

a bug in open_ctree:

struct btrfs_root *open_ctree(..)
{
....
	if (!extent_root || !tree_root || !fs_info ||
	    !chunk_root || !dev_root || !csum_root) {
		err = -ENOMEM;
		goto fail;
//When code flow goes to "fail", fs_info may be NULL or uninitialized.
	}
....

fail:
	btrfs_close_devices(fs_info->fs_devices);// !
	btrfs_mapping_tree_free(&fs_info->mapping_tree);// !

	kfree(extent_root);
	kfree(tree_root);
	bdi_destroy(&fs_info->bdi);// !
...
)

Signed-off-by: Qinghuang Feng <qhfeng.kernel@gmail.com>
---
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 81a3138..f860087 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1828,13 +1828,14 @@ fail_sb_buffer:
 fail_iput:
 	invalidate_inode_pages2(fs_info->btree_inode->i_mapping);
 	iput(fs_info->btree_inode);
-fail:
+
 	btrfs_close_devices(fs_info->fs_devices);
 	btrfs_mapping_tree_free(&fs_info->mapping_tree);
+	bdi_destroy(&fs_info->bdi);
 
+fail:
 	kfree(extent_root);
 	kfree(tree_root);
-	bdi_destroy(&fs_info->bdi);
 	kfree(fs_info);
 	kfree(chunk_root);
 	kfree(dev_root);


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

* Re: [PATCH] Btrfs: fix bug in open_ctree()
  2009-01-17 15:03 [PATCH] Btrfs: fix bug in open_ctree() Qinghuang Feng
@ 2009-01-17 21:29 ` Chris Mason
  0 siblings, 0 replies; 2+ messages in thread
From: Chris Mason @ 2009-01-17 21:29 UTC (permalink / raw)
  To: Qinghuang Feng; +Cc: linux-kernel, linux-btrfs

On Sat, 2009-01-17 at 23:03 +0800, Qinghuang Feng wrote:
> a bug in open_ctree:
> 

Thanks, this looks good.

-chris



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

end of thread, other threads:[~2009-01-17 21:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-17 15:03 [PATCH] Btrfs: fix bug in open_ctree() Qinghuang Feng
2009-01-17 21:29 ` Chris Mason

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox