Btrfs: Check if kobject is initialized before put
authorAnand Jain <Anand.Jain@oracle.com>
Mon, 22 Jun 2015 10:18:32 +0000 (18:18 +0800)
committerDavid Sterba <dsterba@suse.cz>
Mon, 22 Jun 2015 12:43:31 +0000 (14:43 +0200)
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Tested-by: David Sterba <dsterba@suse.cz>
Signed-off-by: David Sterba <dsterba@suse.cz>
fs/btrfs/sysfs.c

index ea81a057c79b98798a454bfbbf93bc50fb39c724..603b0cc2b9bbf627f0b07fec3dad216164e6ddf3 100644 (file)
@@ -523,9 +523,11 @@ static void __btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
                fs_devs->device_dir_kobj = NULL;
        }
 
-       kobject_del(&fs_devs->super_kobj);
-       kobject_put(&fs_devs->super_kobj);
-       wait_for_completion(&fs_devs->kobj_unregister);
+       if (fs_devs->super_kobj.state_initialized) {
+               kobject_del(&fs_devs->super_kobj);
+               kobject_put(&fs_devs->super_kobj);
+               wait_for_completion(&fs_devs->kobj_unregister);
+       }
 }
 
 /* when fs_devs is NULL it will remove all fsid kobject */