Btrfs: do not call kfree if kmalloc failed in btrfs_sysfs_add_super
Signed-off-by: Shen Feng <shen@cn.fujitsu.com>
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 @@
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;
}