summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAnand Jain <Anand.Jain@oracle.com>2015-03-10 06:38:23 +0800
committerDavid Sterba <dsterba@suse.cz>2015-05-27 12:27:19 +0200
commit4d435731f99db87020730c4b17e1da148908340e (patch)
tree0999c9da1b0641d8a77e181508dc030bf20bf7dd /fs
parent8345ea31dc6e1772726d1d0b8864dedac55038e0 (diff)
downloadlinux-stable-4d435731f99db87020730c4b17e1da148908340e.tar.gz
linux-stable-4d435731f99db87020730c4b17e1da148908340e.tar.bz2
linux-stable-4d435731f99db87020730c4b17e1da148908340e.zip
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: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/sysfs.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index f31fcec01e9c..6218d31a6912 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -522,10 +522,12 @@ void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
kobject_del(fs_info->space_info_kobj);
kobject_put(fs_info->space_info_kobj);
}
- btrfs_kobj_rm_device(fs_info, NULL);
- kobject_del(fs_info->device_dir_kobj);
- kobject_put(fs_info->device_dir_kobj);
- fs_info->device_dir_kobj = NULL;
+ if (fs_info->device_dir_kobj) {
+ btrfs_kobj_rm_device(fs_info, NULL);
+ kobject_del(fs_info->device_dir_kobj);
+ kobject_put(fs_info->device_dir_kobj);
+ fs_info->device_dir_kobj = NULL;
+ }
addrm_unknown_feature_attrs(fs_info, false);
sysfs_remove_group(&fs_info->super_kobj, &btrfs_feature_attr_group);
__btrfs_sysfs_remove_one(fs_info);