Commit b126194c authored by Xiao Ni's avatar Xiao Ni Committed by Shaohua Li

MD: Free bioset when md_run fails

Signed-off-by: default avatarXiao Ni <xni@redhat.com>
Acked-by: default avatarGuoqing Jiang <gqjiang@suse.com>
Signed-off-by: default avatarShaohua Li <sh.li@alibaba-inc.com>
parent 4b242e97
...@@ -5497,8 +5497,10 @@ int md_run(struct mddev *mddev) ...@@ -5497,8 +5497,10 @@ int md_run(struct mddev *mddev)
} }
if (mddev->sync_set == NULL) { if (mddev->sync_set == NULL) {
mddev->sync_set = bioset_create(BIO_POOL_SIZE, 0, BIOSET_NEED_BVECS); mddev->sync_set = bioset_create(BIO_POOL_SIZE, 0, BIOSET_NEED_BVECS);
if (!mddev->sync_set) if (!mddev->sync_set) {
return -ENOMEM; err = -ENOMEM;
goto abort;
}
} }
spin_lock(&pers_lock); spin_lock(&pers_lock);
...@@ -5511,7 +5513,8 @@ int md_run(struct mddev *mddev) ...@@ -5511,7 +5513,8 @@ int md_run(struct mddev *mddev)
else else
pr_warn("md: personality for level %s is not loaded!\n", pr_warn("md: personality for level %s is not loaded!\n",
mddev->clevel); mddev->clevel);
return -EINVAL; err = -EINVAL;
goto abort;
} }
spin_unlock(&pers_lock); spin_unlock(&pers_lock);
if (mddev->level != pers->level) { if (mddev->level != pers->level) {
...@@ -5524,7 +5527,8 @@ int md_run(struct mddev *mddev) ...@@ -5524,7 +5527,8 @@ int md_run(struct mddev *mddev)
pers->start_reshape == NULL) { pers->start_reshape == NULL) {
/* This personality cannot handle reshaping... */ /* This personality cannot handle reshaping... */
module_put(pers->owner); module_put(pers->owner);
return -EINVAL; err = -EINVAL;
goto abort;
} }
if (pers->sync_request) { if (pers->sync_request) {
...@@ -5593,7 +5597,7 @@ int md_run(struct mddev *mddev) ...@@ -5593,7 +5597,7 @@ int md_run(struct mddev *mddev)
mddev->private = NULL; mddev->private = NULL;
module_put(pers->owner); module_put(pers->owner);
bitmap_destroy(mddev); bitmap_destroy(mddev);
return err; goto abort;
} }
if (mddev->queue) { if (mddev->queue) {
bool nonrot = true; bool nonrot = true;
...@@ -5655,6 +5659,18 @@ int md_run(struct mddev *mddev) ...@@ -5655,6 +5659,18 @@ int md_run(struct mddev *mddev)
sysfs_notify_dirent_safe(mddev->sysfs_action); sysfs_notify_dirent_safe(mddev->sysfs_action);
sysfs_notify(&mddev->kobj, NULL, "degraded"); sysfs_notify(&mddev->kobj, NULL, "degraded");
return 0; return 0;
abort:
if (mddev->bio_set) {
bioset_free(mddev->bio_set);
mddev->bio_set = NULL;
}
if (mddev->sync_set) {
bioset_free(mddev->sync_set);
mddev->sync_set = NULL;
}
return err;
} }
EXPORT_SYMBOL_GPL(md_run); EXPORT_SYMBOL_GPL(md_run);
......
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