public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Btrfs: do not call kfree if kmalloc failed in btrfs_sysfs_add_super
@ 2008-12-29  3:44 Shen Feng
  0 siblings, 0 replies; only message in thread
From: Shen Feng @ 2008-12-29  3:44 UTC (permalink / raw)
  To: linux-btrfs

kfree should not be called if kmalloc is not success.

Signed-off-by: Shen Feng <shen@cn.fujitsu.com>
---
 fs/btrfs/sysfs.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 300076e..04087c0 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -212,14 +212,13 @@ int btrfs_sysfs_add_super(struct btrfs_fs_info *fs)
 	fs->super_kobj.kset = btrfs_kset;
 	error = kobject_init_and_add(&fs->super_kobj, &btrfs_super_ktype,
 				     NULL, "%s", name);
+	kfree(name);
 	if (error)
 		goto fail;
 
-	kfree(name);
 	return 0;
 
 fail:
-	kfree(name);
 	printk(KERN_ERR "btrfs: sysfs creation for super failed\n");
 	return error;
 }
-- 
1.6.0.6



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2008-12-29  3:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-29  3:44 [PATCH] Btrfs: do not call kfree if kmalloc failed in btrfs_sysfs_add_super Shen Feng

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