Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp172548imd; Wed, 31 Oct 2018 16:46:52 -0700 (PDT) X-Google-Smtp-Source: AJdET5fwRFrxDK5QBddZXExKbES5YEOMiQoWFv883aYg0YJkGkqraX7wMw/YLJ+YZm9zptEyVqU0 X-Received: by 2002:a65:594b:: with SMTP id g11-v6mr4841902pgu.229.1541029612655; Wed, 31 Oct 2018 16:46:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541029612; cv=none; d=google.com; s=arc-20160816; b=fWSFDjX3llND+drt73qs+7aJB0U411WkSsM6qP0+TO+j2CznYb4IAO8zKzjI6YuT4O PFU0g5YmctYC9cVJP2Ec/X/IGiT34frMNrxCl+Li3H0aU6k49BZaZw0jOtb7h00idqQ9 PnKJX9gzL+9ZZEsxxeqtW6pKcrB0T615xt/47eIrKK0HDUCe4UBDcH09SNAxlWVACYIB YKKunR8tYsPGk7B/LVRHigwgXYCnO217OGRRahsHrbclLlrZUHXuMo+4m9ze68j/ulNi LYWRqxdoOsquk6MCFHg1L862biN6HWKBHtoLFW3uBdUBq1Q/RULm6STSAGFiqV8vFR+s HOPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=nwZuE7z75ZkEgKI+S/PrqjKs2kbW34GuVD06OJngZY4=; b=fR+uPzGYlFnt2eoN0+sHd6MOHswy8pZkJ/Bi0xtoeqEfCDERTZZaWbtqAEQc2NrFkE +tIi5u+dgtOs77NAmNeJMIMlvtVGwGQz8YJXH1ecScbbhKMjCq3JW5Zi8uYCL3YDQx2K F4a4D08v28K3ZQHcQAToNe5YGJebQ6K6KM61ftUhogAtw/CQpffkxDc3KxPu0te+mcaY hU57CWta748i9bWpwpCu75AlTRKGN0BPxUOxB2mzahuEbe3aEWtjiaMIwTN+1J4HtEVF pWmS7tokUYK3pjRUn9d1iqxpPD5j+dP2+aKlgxBG/4FKVtJTWBvgi7U1dBM0aQ4SfeD5 DDuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oS8ufkyr; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 20-v6si28830099pfk.287.2018.10.31.16.46.38; Wed, 31 Oct 2018 16:46:52 -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=oS8ufkyr; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728757AbeKAIHS (ORCPT + 99 others); Thu, 1 Nov 2018 04:07:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:54822 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728646AbeKAIHO (ORCPT ); Thu, 1 Nov 2018 04:07:14 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 149D320840; Wed, 31 Oct 2018 23:07:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027223; bh=T1KXXEbo/2TZKhA3E8FGyXxqa5b5MRrLIA+lKK6BBxo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oS8ufkyrU9jQ96v0oVaabJDkLc09zEG2Shpq30t7QRiomMkpgtGV8qnB2F2PdN9+Q jA4ytDnXe9EnX9G5Puw1LAGNGqb8Fo0M1Z55SLxTw0As4Ks4xulj+XbOXpq3pjPf+Q /vdKtSV+gSZdHjzeBOpJ302Et3OOZpE7EfoC2mHQ= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Xiao Ni , David Jeffery , Shaohua Li , Sasha Levin Subject: [PATCH AUTOSEL 4.19 089/146] MD: Memory leak when flush bio size is zero Date: Wed, 31 Oct 2018 19:04:44 -0400 Message-Id: <20181031230541.28822-89-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/md/md.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 63ceabb4e020..06f68f19b5f3 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -452,10 +452,11 @@ static void md_end_flush(struct bio *fbio) 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 *mddev, struct bio *bio) 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); } -- 2.17.1