Btrfs: sysfs: fix, kobject pointer clean up needed after kobject release
authorAnand Jain <Anand.Jain@oracle.com>
Fri, 20 Mar 2015 10:01:20 +0000 (18:01 +0800)
committerDavid Sterba <dsterba@suse.cz>
Wed, 27 May 2015 10:27:19 +0000 (12:27 +0200)
The sysfs clean up self test like in the below code fails, since
fs_info->device_dir_kobject still points to its stale kobject.
Reseting this pointer will help to fix this.

open_ctree()
{

ret = btrfs_sysfs_add_one(fs_info);
::
+       btrfs_sysfs_remove_one(fs_info);
+       ret = btrfs_sysfs_add_one(fs_info);
+       if (ret) {
+               pr_err("BTRFS: failed to init sysfs interface: %d\n", ret);
+               goto fail_block_groups;
+       }

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
fs/btrfs/sysfs.c

index ca0786190eddadf27650be8342a76acb796363ab..f31fcec01e9cb7901c244fbb798430429190b9b7 100644 (file)
@@ -525,6 +525,7 @@ void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
        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);