From patchwork Tue Oct 27 13:54:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 307162 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE9CDC56201 for ; Tue, 27 Oct 2020 17:22:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 74AE82076B for ; Tue, 27 Oct 2020 17:22:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603819348; bh=+kDMFYPNlsQUHUHKdFrxk0ckCdUURXek0l2hYWeThDI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=XGmHxwLQMCzZdqopC3xQkRGGTJ1LaXr697GQ2UZcjFQo3oixaQLqAp3qMOGRVBhtV o/eMQncocwNyoXrn7gCPFGhndXB1bJcA5S9ja1/jUSTI6ecWwDvtDcEsXnLa3bNhYd fjgSE9+whP2aai0rTBTzxEZevvxi5ZD5hgGNAF2U= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S368550AbgJ0Oy5 (ORCPT ); Tue, 27 Oct 2020 10:54:57 -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 Precedence: bulk List-ID: X-Mailing-List: stable@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;