Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3483793imu; Sun, 11 Nov 2018 16:08:21 -0800 (PST) X-Google-Smtp-Source: AJdET5fNuldm+0V5OiFZVVf13RbVSKOFFF2jtb2DRjN3e7xBNPAIBsF7zwHyTxfkSuCqOgZlIZwG X-Received: by 2002:a63:1258:: with SMTP id 24mr15352135pgs.114.1541981300943; Sun, 11 Nov 2018 16:08:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981300; cv=none; d=google.com; s=arc-20160816; b=qM1KK2NusjBTr2UZsIPDT6ent+mDBEWVYA4gCdAHcPBNK5TtDjR9caVQBiWK6vmLvv 9+zBxRTJJmRR4CPskZnfiXzOLNG/utFjI78c2KRXplzNpGBnAXXvxKZpT9ZEsZ7bcsFE Vnv0m4Me8SIpzboB/WRJsNkPGYtBQtXnkBdeEMU6lSuAARYeWfrMSBjhUgHsdBky8/dJ e5NfZo4/DNlFOe7Q7qUzT2G19ovgLXIi3Ihsx7EdCfkW6dxHmTC1+M/Sf7F5IqBSBqQK lfibSdaAvN5JPUIbbq/S3yjQbsY0JprnSGTa/ps71zLrUfi06DdWieoFeKQCIyhoK3dY XpSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fM8eAvOvLzT7ICJmna2srAYhNrFYIQOvnVEw1JNUmNk=; b=Y+riz42gzXYKkn+RseEZpVTc3ET/gz8Q/+jmYCyJ4u8FSxVAJgWOsIlwNeaKpDC2Ck dt6KRheEHy94ySxWVDkG1w/FQxSjca++YM2tWVasvjCjkAYq+HCqh/othYm4+jxGRi1G llPCBc+ws1YnNaBkfi9fUHCL3XMe83z/ODmXQ6tgkQqqgpPUNEKIQoiDJXkmrZTJrwpg WuLJ1rlNAh/Elqxn+rHgclBQuLX79/2Ld5VgHCBX/OjpA9ZPJX20hJvQriewTwv0yJ6m oYJ6SxPfqUhwcoFzT3xenhu1haqSAAT2wnTQ3sz1z9vES0OSuemAgnukXl3PbAvrHmpT 4Hqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OqjGesQA; 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 133si13803959pge.246.2018.11.11.16.08.06; Sun, 11 Nov 2018 16:08:20 -0800 (PST) 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=OqjGesQA; 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 S1731639AbeKLIRe (ORCPT + 99 others); Mon, 12 Nov 2018 03:17:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:60278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731159AbeKLIRd (ORCPT ); Mon, 12 Nov 2018 03:17:33 -0500 Received: from localhost (unknown [206.108.79.134]) (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 17ED5214E0; Sun, 11 Nov 2018 22:27:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975258; bh=kyp9eh3FMcDiVTElO+0tcH8yFewdKMb2R8XEgKVPc6g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OqjGesQASjqkOXwlDoqMIG5OzXZk7qeiWmRsolJmAirLqpiUnmGZqAp9rcgQCWifU 2QhwPdQF5+S818f6KgRks+kuyXi1SKdDzjxnGN3RI+6P925RrWPsjbdTuwFcohAt6i N7LL1KcEfh4T/OKq4Ij26PhBbDkXc3xGenE6Aeoo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Jeffery , Xiao Ni , Shaohua Li , Sasha Levin Subject: [PATCH 4.19 134/361] MD: Memory leak when flush bio size is zero Date: Sun, 11 Nov 2018 14:18:01 -0800 Message-Id: <20181111221639.154959645@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xiao Ni [ Upstream commit af9b926de9c5986ab009e64917de87c9758bab10 ] flush_pool is leaked when flush bio size is zero Fixes: 5a409b4f56d5 ("MD: fix lock contention for flush bios") Signed-off-by: David Jeffery Signed-off-by: Xiao Ni Signed-off-by: Shaohua Li Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/md/md.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -452,10 +452,11 @@ static void md_end_flush(struct bio *fbi rdev_dec_pending(rdev, mddev); if (atomic_dec_and_test(&fi->flush_pending)) { - if (bio->bi_iter.bi_size == 0) + if (bio->bi_iter.bi_size == 0) { /* an empty barrier - all done */ bio_endio(bio); - else { + mempool_free(fi, mddev->flush_pool); + } else { INIT_WORK(&fi->flush_work, submit_flushes); queue_work(md_wq, &fi->flush_work); } @@ -509,10 +510,11 @@ void md_flush_request(struct mddev *mdde rcu_read_unlock(); if (atomic_dec_and_test(&fi->flush_pending)) { - if (bio->bi_iter.bi_size == 0) + if (bio->bi_iter.bi_size == 0) { /* an empty barrier - all done */ bio_endio(bio); - else { + mempool_free(fi, mddev->flush_pool); + } else { INIT_WORK(&fi->flush_work, submit_flushes); queue_work(md_wq, &fi->flush_work); }