Commit a21d1504 authored by NeilBrown's avatar NeilBrown

md: centralise all freeing of an 'mddev' in 'md_free'

md_free is the .release handler for the md kobj_type.
So it makes sense to release all the objects referenced by
the mddev in there, rather than just prior to calling kobject_put
for what we think is the last time.
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent 8b765398
...@@ -221,12 +221,6 @@ static void mddev_put(mddev_t *mddev) ...@@ -221,12 +221,6 @@ static void mddev_put(mddev_t *mddev)
if (!mddev->raid_disks && list_empty(&mddev->disks)) { if (!mddev->raid_disks && list_empty(&mddev->disks)) {
list_del(&mddev->all_mddevs); list_del(&mddev->all_mddevs);
spin_unlock(&all_mddevs_lock); spin_unlock(&all_mddevs_lock);
if (mddev->queue)
blk_cleanup_queue(mddev->queue);
mddev->queue = NULL;
if (mddev->sysfs_state)
sysfs_put(mddev->sysfs_state);
mddev->sysfs_state = NULL;
kobject_put(&mddev->kobj); kobject_put(&mddev->kobj);
} else } else
spin_unlock(&all_mddevs_lock); spin_unlock(&all_mddevs_lock);
...@@ -3451,6 +3445,17 @@ md_attr_store(struct kobject *kobj, struct attribute *attr, ...@@ -3451,6 +3445,17 @@ md_attr_store(struct kobject *kobj, struct attribute *attr,
static void md_free(struct kobject *ko) static void md_free(struct kobject *ko)
{ {
mddev_t *mddev = container_of(ko, mddev_t, kobj); mddev_t *mddev = container_of(ko, mddev_t, kobj);
if (mddev->sysfs_state)
sysfs_put(mddev->sysfs_state);
if (mddev->gendisk) {
del_gendisk(mddev->gendisk);
put_disk(mddev->gendisk);
}
if (mddev->queue)
blk_cleanup_queue(mddev->queue);
kfree(mddev); kfree(mddev);
} }
...@@ -6435,9 +6440,6 @@ static __exit void md_exit(void) ...@@ -6435,9 +6440,6 @@ static __exit void md_exit(void)
if (!disk) if (!disk)
continue; continue;
export_array(mddev); export_array(mddev);
del_gendisk(disk);
put_disk(disk);
mddev->gendisk = NULL;
mddev_put(mddev); mddev_put(mddev);
} }
} }
......
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