Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2197695imm; Mon, 28 May 2018 03:45:26 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqxia9UUljYCLp6s6BYpfJV/3YrA/GUi5Ec2PS7PgDqj5/AXH7EKjN+jW7bglC6eqaUk1Qe X-Received: by 2002:a65:52c8:: with SMTP id z8-v6mr10284553pgp.46.1527504326372; Mon, 28 May 2018 03:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527504326; cv=none; d=google.com; s=arc-20160816; b=y2VP2PcVMG6sgklzDV5IUgKfO9E+1EnU6vj64c8Eedan3pCUWRVove35qN8/bAmZ8r XpGuTmWd29CUo03h+hCM2KaNtcIky91e2sX4bqM7irLGiOOLdHFdOW+Nd+SzC1y2tSib n/V+nj5Je9/fHvCVrwfcTJSnFxHiZOwWuuHBR3yT9JnH61yuTCCQvCTSLBFm0zzvR60m HQKS8l2Pz7+QaPdWB6RZ83Frj6zAMyW0tbjXFbnh6yikb5/jfeAZ0MRJDnRI303rLsMG nfGJj3z0Liay6L/mVbGUVBOwyQG7CUYubVwu3Qq6GTvFn42WvmWYDnHbbE1N321lCZEN mxKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=9uUHzJ2vIZ23LNry85x/4Hef2nVSc+jSigH/SycETYY=; b=AULC+sdze0TFsQ+1K3fGNCc23J1orM/d5Ss7KOsl21vx2lVlE8ir9BmS58ooVFUHeV 965Xo+Q2fic5poPSVSzK1vVh6obCUqssSlBtRrhP+WySl+pm12dPv/uorRGiofZE6bey 0cnM74fiuiuLMy3UsVcJE2WeB5eB+ynAzUytiMc1biPUzQOjjlBctgyHfoLZZCRONLW3 iCX3GZ8O6ztzCuUDPzH8QBghOMqSSxDjQ2GvTfY13kLPJM75I40HGqOY1/UaV3gYVSBx rgBfsfuUOWJ8KthyP8BqUkUUascTcgE+HPgyaVpJZw4aavGCpwgfxNDoKCOvPfjxJ4DT qWRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ia8nFNyr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i135-v6si5296154pgc.118.2018.05.28.03.45.11; Mon, 28 May 2018 03:45:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ia8nFNyr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937713AbeE1KpJ (ORCPT + 99 others); Mon, 28 May 2018 06:45:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:35570 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163096AbeE1Ko5 (ORCPT ); Mon, 28 May 2018 06:44:57 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1983D204EE; Mon, 28 May 2018 10:44:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527504296; bh=EVRjlZsb/ZHkkrWrWl+Uev/W9dj5xf5g+rR7ME59EGg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ia8nFNyrAt+xPYUFt3jvvWoLjDAv6soHGGYMLCKvi720oN/57lLVEehh9qaHb3wsz tEc2KwYALhw4UDFAipoz1tI2Gbef2zDQDB5biN5kewH/7nvI4QDn+tTGNe2CXgSQ/9 LocY/FdHkfXrgSu8Ejh/joskD3m08pBcRRPMhE6s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiao Ni , Guoqing Jiang , Shaohua Li , Sasha Levin Subject: [PATCH 4.14 087/496] MD: Free bioset when md_run fails Date: Mon, 28 May 2018 11:57:52 +0200 Message-Id: <20180528100323.467858579@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xiao Ni [ Upstream commit b126194cbb799f9980b92a77e58db6ad794c8082 ] Signed-off-by: Xiao Ni Acked-by: Guoqing Jiang Signed-off-by: Shaohua Li Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- 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);