lkml.org 
[lkml]   [2018]   [May]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.14 087/496] MD: Free bioset when md_run fails
    Date
    4.14-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Xiao Ni <xni@redhat.com>

    [ Upstream commit b126194cbb799f9980b92a77e58db6ad794c8082 ]

    Signed-off-by: Xiao Ni <xni@redhat.com>
    Acked-by: Guoqing Jiang <gqjiang@suse.com>
    Signed-off-by: Shaohua Li <sh.li@alibaba-inc.com>
    Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    drivers/md/md.c | 26 +++++++++++++++++++++-----
    1 file changed, 21 insertions(+), 5 deletions(-)

    --- a/drivers/md/md.c
    +++ b/drivers/md/md.c
    @@ -5479,8 +5479,10 @@ int md_run(struct mddev *mddev)
    }
    if (mddev->sync_set == NULL) {
    mddev->sync_set = bioset_create(BIO_POOL_SIZE, 0, BIOSET_NEED_BVECS);
    - if (!mddev->sync_set)
    - return -ENOMEM;
    + if (!mddev->sync_set) {
    + err = -ENOMEM;
    + goto abort;
    + }
    }

    spin_lock(&pers_lock);
    @@ -5493,7 +5495,8 @@ int md_run(struct mddev *mddev)
    else
    pr_warn("md: personality for level %s is not loaded!\n",
    mddev->clevel);
    - return -EINVAL;
    + err = -EINVAL;
    + goto abort;
    }
    spin_unlock(&pers_lock);
    if (mddev->level != pers->level) {
    @@ -5506,7 +5509,8 @@ int md_run(struct mddev *mddev)
    pers->start_reshape == NULL) {
    /* This personality cannot handle reshaping... */
    module_put(pers->owner);
    - return -EINVAL;
    + err = -EINVAL;
    + goto abort;
    }

    if (pers->sync_request) {
    @@ -5580,7 +5584,7 @@ int md_run(struct mddev *mddev)
    mddev->private = NULL;
    module_put(pers->owner);
    bitmap_destroy(mddev);
    - return err;
    + goto abort;
    }
    if (mddev->queue) {
    bool nonrot = true;
    @@ -5642,6 +5646,18 @@ int md_run(struct mddev *mddev)
    sysfs_notify_dirent_safe(mddev->sysfs_action);
    sysfs_notify(&mddev->kobj, NULL, "degraded");
    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);


    \
     
     \ /
      Last update: 2018-05-28 15:39    [W:4.553 / U:0.008 seconds]
    ©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site