Skip to contentSkip to conversation

Btrfs: do not call kfree if kmalloc failed in btrfs_sysfs_add_super

PATCH New Shen Feng 1 participant 1 message Dec 29, 2008 Btrfs file system

lore
Share & tools
lore

Shen Feng

author
#0 lore raw

PATCH 1/1 Btrfs: do not call kfree if kmalloc failed in btrfs_sysfs_add_super

kfree should not be called if kmalloc is not success.

---
 fs/btrfs/sysfs.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
fs/btrfs/sysfs.c +1 -2
index 300076e..04087c0 100644
@@ -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;
 }
Signature · 1 line
1.6.0.6