Commit 4d435731 authored by Anand Jain's avatar Anand Jain Committed by David Sterba

Btrfc: sysfs: fix, check if device_dir_kobj is init before destroy

Since the failure code in the btrfs_sysfs_add_one() can
call btrfs_sysfs_remove_one() even before device_dir_kobj
has been created we need to check if its null.
Signed-off-by: default avatarAnand Jain <anand.jain@oracle.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.cz>
parent 8345ea31
...@@ -522,10 +522,12 @@ void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info) ...@@ -522,10 +522,12 @@ void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
kobject_del(fs_info->space_info_kobj); kobject_del(fs_info->space_info_kobj);
kobject_put(fs_info->space_info_kobj); kobject_put(fs_info->space_info_kobj);
} }
if (fs_info->device_dir_kobj) {
btrfs_kobj_rm_device(fs_info, NULL); btrfs_kobj_rm_device(fs_info, NULL);
kobject_del(fs_info->device_dir_kobj); kobject_del(fs_info->device_dir_kobj);
kobject_put(fs_info->device_dir_kobj); kobject_put(fs_info->device_dir_kobj);
fs_info->device_dir_kobj = NULL; fs_info->device_dir_kobj = NULL;
}
addrm_unknown_feature_attrs(fs_info, false); addrm_unknown_feature_attrs(fs_info, false);
sysfs_remove_group(&fs_info->super_kobj, &btrfs_feature_attr_group); sysfs_remove_group(&fs_info->super_kobj, &btrfs_feature_attr_group);
__btrfs_sysfs_remove_one(fs_info); __btrfs_sysfs_remove_one(fs_info);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment