Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1104628pxa; Thu, 20 Aug 2020 02:35:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOPpCR0LQMTdWNgcr4HOLWIz+eyCUu8qqn2ll9R/thlNkAYbkfecXa/ENiiPnHDKpCXz1h X-Received: by 2002:a17:907:385:: with SMTP id ss5mr2288185ejb.496.1597916121897; Thu, 20 Aug 2020 02:35:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597916121; cv=none; d=google.com; s=arc-20160816; b=xqwVFKIuRJjdgAlTRxgfGa0RKEBNcV1fW9szERCpQuRHFk74kTz2pWIA+I5xbnB8md 2UBMIFqXNllSEfqPiC/Bhb6/FcjKELZgI1L/L4Vna/seri5Yuwb0D7X8lIl5DD1+stTJ i13SG8VHOTkCwbNQrvu6s+geUJs7V2fBtek79IVEwQcYREZ7TLS0K3hy+huLHUTlRH2j pU4z6Wgo87d6sfZpph5tH2bnXnomiFygylCsFtIgfbRO28UmohuntwYZEzIH/1lZ7L6k xMuvAZ0WNYIkBt67PKYHAUjY+W4pga+eG5+nxgoUojA6iUIsfiUK4tmKtq82MtkTb0wq YLgQ== 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=hxUh9BXi2fN//xl7meM5TGKTBhjA428nts14Uc+el7c=; b=loDLIqeG5lq6fxf6pCSptiN/NjQVNXik9/ysUv7wxYxU19lTg7SaXaBpeWUGZ2K8Qt mebgvIq3fkRu023wcjb/WLYz3YKSLE07085PlwQLQZAR4I27pWI5tnXXTnbK+W/OQ2v4 6EplIh06I/Wj9WsIoUdb5L1pGVkUqx8ZDIvsOFLegx8OJy2sCKXv0nw6d19npZG1DizK YaKHrgoSLnyT4nqviDlANPvZyCjRIb6jMyTuALan2+U9KBauvxDZRIw9lP5qO4XCu5qg tb8AE7TI44MiGBfeKbZ/JJlt6AN6Lqg7iRMjshWNTZQK8XwZYfDBQLzK1Ew8jt+qp06I OmCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bcuOoSX+; 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 dt16si773827ejb.353.2020.08.20.02.34.58; Thu, 20 Aug 2020 02:35:21 -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=bcuOoSX+; 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 S1727994AbgHTJcR (ORCPT + 99 others); Thu, 20 Aug 2020 05:32:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:43850 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728246AbgHTJbo (ORCPT ); Thu, 20 Aug 2020 05:31:44 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 B664822B4E; Thu, 20 Aug 2020 09:31:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915904; bh=E9us+8P+2swPNnKOpTkvu4a59RwLHeKEXwH8xJTtIMc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bcuOoSX+A/ihrwHO8L9jpMKZbcOFYlggaer586//rAi+h2iutHFR6X6ioOIDf09Ot 8i4hEg+aWLLKB/533Jov3WKsz+2IRq9U/ayEy3uxSNrZ1HLV4AJOoZSwgEKpWnjax7 HK67Ib3N8ql3Ql1X3jho6utmeOjVPnC1IH1EQdCs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhihao Cheng , Richard Weinberger , Sasha Levin Subject: [PATCH 5.8 175/232] ubi: fastmap: Free fastmap next anchor peb during detach Date: Thu, 20 Aug 2020 11:20:26 +0200 Message-Id: <20200820091621.294484832@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Zhihao Cheng [ Upstream commit c3fc1a3919e35a9d8157ed3ae6fd0a478293ba2c ] ubi_wl_entry related with the fm_next_anchor PEB is not freed during detach, which causes a memory leak. Don't forget to release fm_next_anchor PEB while detaching ubi from mtd when CONFIG_MTD_UBI_FASTMAP is enabled. Signed-off-by: Zhihao Cheng Fixes: 4b68bf9a69d22d ("ubi: Select fastmap anchor PEBs considering...") Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin --- drivers/mtd/ubi/fastmap-wl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/mtd/ubi/fastmap-wl.c b/drivers/mtd/ubi/fastmap-wl.c index 83afc00e365a5..28f55f9cf7153 100644 --- a/drivers/mtd/ubi/fastmap-wl.c +++ b/drivers/mtd/ubi/fastmap-wl.c @@ -381,6 +381,11 @@ static void ubi_fastmap_close(struct ubi_device *ubi) ubi->fm_anchor = NULL; } + if (ubi->fm_next_anchor) { + return_unused_peb(ubi, ubi->fm_next_anchor); + ubi->fm_next_anchor = NULL; + } + if (ubi->fm) { for (i = 0; i < ubi->fm->used_blocks; i++) kfree(ubi->fm->e[i]); -- 2.25.1