Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp255383pxx; Wed, 28 Oct 2020 04:13:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkjExs62QDwmfpBU4wW0MXIwXV2N9kvDIKPm/wow2xD/1NaBIakA3PL4xh7J9LZ9DuBO48 X-Received: by 2002:a05:6402:a45:: with SMTP id bt5mr7295221edb.101.1603883622104; Wed, 28 Oct 2020 04:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603883622; cv=none; d=google.com; s=arc-20160816; b=M9JtwqXFzBsTXG3tAAPJtpV7t8ngdCxj0r9hFkC9XxLKnyCW+mOTQyXyWl+bDaT18j 0+y8aW7lcaTft17PPw43VTeXZ2ZE7py48PrMTu2Y/Mub0vOdABgkv5KsZF+FYWLNYTYe YIE/yIXoWxjdZ7rQfMaBG4Fgl6Uj1h7YRYQwSKpRZ08HSw/VhUcZp4D6jf/EkaSZa+MU /mS76whQlm3Z7ubBcEiAdjmYd70IPpHU5Gq2Xbckt7iXiqo4fTa2ANjQy0GKAumHPZmG B0GgPuOZV4TzGpywCp4Svzg865+ESD+gNYqGP/VpD53OZHcBoFgcyGyqCdTXXi5FmMD/ 7eVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=F6OO7ccIjVw71rP7PjjEQWWhjbkn7EHV6Y6BLwX7O2o=; b=j1apqaWA5zauHaAZivc/wihbX0gGYYylXYC6ErP6xb5gvU3lBrJRltPNIls7Z25IH3 oNAA4/aEGPNyWXZpj9kbxn9DECapgOqY5LwqBqr7WhsTzDmlitJZ8BtuNj8DogZWb4B3 GHYY/uFjUVwhuhck/WZz1I8nZBHDMAjf5BdXs5oPTtyjbW9R7zcnkTL9l661aHYNB8VN KtxOasGyEyV8JAqIal/RRVMIRSJjYlwPMR/5HWqx8ZsDFSDSx3gIcbZtx3om/DpVSvB2 PZ+XNTj22LW7m26ouedhZCuW4cdU283EiZyzlcf2QyBiSlo6K6vVRmccRwDLUC+NL2G/ JBtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rQNwqJhk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk22si2709939edb.258.2020.10.28.04.13.19; Wed, 28 Oct 2020 04:13:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rQNwqJhk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1787154AbgJ0PAA (ORCPT + 99 others); Tue, 27 Oct 2020 11:00:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:43084 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750872AbgJ0OnT (ORCPT ); Tue, 27 Oct 2020 10:43:19 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 0D5972222C; Tue, 27 Oct 2020 14:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809798; bh=+kDMFYPNlsQUHUHKdFrxk0ckCdUURXek0l2hYWeThDI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rQNwqJhkHayYBh5bAKBbUY799WbDWOyHksD23DGPSit5ICQVnqyMt9mAPxeZ3yA03 IsNU9Woo1dwuRNDgite6uMuu2nGF0nGj8x7O9Rqqrop+TQWLRwJGUIyVyy+RUp3S/h FM1268LoqarcpzoMmSLRPJaijvDqtUyxtxs1AhBs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guoqing Jiang , Zhao Heming , Song Liu , Sasha Levin Subject: [PATCH 5.4 324/408] md/bitmap: fix memory leak of temporary bitmap Date: Tue, 27 Oct 2020 14:54:22 +0100 Message-Id: <20201027135510.055053083@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhao Heming [ Upstream commit 1383b347a8ae4a69c04ae3746e6cb5c8d38e2585 ] Callers of get_bitmap_from_slot() are responsible to free the bitmap. Suggested-by: Guoqing Jiang Signed-off-by: Zhao Heming Signed-off-by: Song Liu Signed-off-by: Sasha Levin --- drivers/md/md-bitmap.c | 3 ++- drivers/md/md-cluster.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 3ad18246fcb3c..7227d03dbbea7 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1954,6 +1954,7 @@ int md_bitmap_load(struct mddev *mddev) } EXPORT_SYMBOL_GPL(md_bitmap_load); +/* caller need to free returned bitmap with md_bitmap_free() */ struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot) { int rv = 0; @@ -2017,6 +2018,7 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot, md_bitmap_unplug(mddev->bitmap); *low = lo; *high = hi; + md_bitmap_free(bitmap); return rv; } @@ -2620,4 +2622,3 @@ struct attribute_group md_bitmap_group = { .name = "bitmap", .attrs = md_bitmap_attrs, }; - diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c index d50737ec40394..afbbc552c3275 100644 --- a/drivers/md/md-cluster.c +++ b/drivers/md/md-cluster.c @@ -1166,6 +1166,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz * can't resize bitmap */ goto out; + md_bitmap_free(bitmap); } return 0; -- 2.25.1