Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp446612iog; Mon, 13 Jun 2022 06:09:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnsDuy1Um36Tx4AD+WndbqWcjDWhEU7XwyVfFnQ9nBrdIKzN4eEG1S6lCgRiIDQ6IOgydZ X-Received: by 2002:a63:8841:0:b0:3fc:704c:24ff with SMTP id l62-20020a638841000000b003fc704c24ffmr51807605pgd.116.1655125660466; Mon, 13 Jun 2022 06:07:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125660; cv=none; d=google.com; s=arc-20160816; b=I5WR/rELaKTqfF/p8skQIYv8k6XjhTLjHfJNVTA2tfNVdROhEE08AWBervuHfyR8Bx YSgOBoowIo9wLDQahIj91y/cNlfYsU/LeKF66URcWUJ6XChWT6zHogWEpxTeVUvryGZ8 YFmT+ZRdQd0VSosJLAvMoWPohE7cKE6/Ta0+WNpAnbL8UEFhfnrygxjS69kxkxaRzO8T /NlvaxwGl+PUm6Qd3l7fjFjEeelFd9r28RTUeU09eY8EyGh+KJQkqm6/lpkK2hDgSHcY d7LtiTKEsO9JS8mLpwyh9K6Fk5rXLmEMZS8TNB6mycP+9OUC6RutZWtx7uWs44kjFBB6 UYZw== 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=mPamG4oKQXGr8cMKC+8ORJECVTnS9IBAK6du9nWuw5Y=; b=bXLO18MxodICBT0xuVHL37J7TlbNIBW+N1K5wknIw3mSFyBYrgtzKOFdi6wVh9+CnM C4KMut7aYQd/4/oKR83fIAf7wcqQiDKD3YNykKBm0z8WSUrfJjbn/Ih0ehXqiCSVxsWy JdDAnDMY9SRb9nDJOBagsA11+cWSUJu4ddyi0Y0VevAFlDSyeZUPjGvdVWvWmkssCPXL dws9eJPQhOev3Ga5/J8yHSk9TMxwfLu6wARccCFTvobijniL3qam8zm6P31lvM0CVF8s 6pkP1ULaz+t9ZVciHv7/p0/Y0QXriq8JKTukT19+79+BBgDBo9ITtryY0u0pLA6lu6Vg KG2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UB7qGzLL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b36-20020a631b24000000b003fbc1902fe6si8995075pgb.706.2022.06.13.06.07.26; Mon, 13 Jun 2022 06:07:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UB7qGzLL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351578AbiFMLEo (ORCPT + 99 others); Mon, 13 Jun 2022 07:04:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350372AbiFMKyv (ORCPT ); Mon, 13 Jun 2022 06:54:51 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 208241EC5A; Mon, 13 Jun 2022 03:31:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C95CFB80E5E; Mon, 13 Jun 2022 10:31:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27F40C34114; Mon, 13 Jun 2022 10:31:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116267; bh=OV+yhI+AIapZZVpxSGNeAn9wZrponTmOw5vBnxD9cug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UB7qGzLLoEjlbDY+N+zJX4n4w0DM/4TY1MUuuswYEsDHu/gtE45uJfAGDpWgrmuwI m81r6na4So4y5UaKlduPR5doVpZnWOgsJnH4/Mn3KiUdQVM7dyPas4aQOlCi0x4ofV lKKMTZx5RQ6mL+8JdMVGOYWukDth32S9AEfkG+wM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Baokun Li , Richard Weinberger , Sasha Levin Subject: [PATCH 4.14 161/218] jffs2: fix memory leak in jffs2_do_fill_super Date: Mon, 13 Jun 2022 12:10:19 +0200 Message-Id: <20220613094925.479983497@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094908.257446132@linuxfoundation.org> References: <20220613094908.257446132@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Baokun Li [ Upstream commit c14adb1cf70a984ed081c67e9d27bc3caad9537c ] If jffs2_iget() or d_make_root() in jffs2_do_fill_super() returns an error, we can observe the following kmemleak report: -------------------------------------------- unreferenced object 0xffff888105a65340 (size 64): comm "mount", pid 710, jiffies 4302851558 (age 58.239s) hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [] kmem_cache_alloc_trace+0x475/0x8a0 [] jffs2_sum_init+0x96/0x1a0 [] jffs2_do_mount_fs+0x745/0x2120 [] jffs2_do_fill_super+0x35c/0x810 [] jffs2_fill_super+0x2b9/0x3b0 [...] unreferenced object 0xffff8881bd7f0000 (size 65536): comm "mount", pid 710, jiffies 4302851558 (age 58.239s) hex dump (first 32 bytes): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb ................ bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb ................ backtrace: [] kmalloc_order+0xda/0x110 [] kmalloc_order_trace+0x21/0x130 [] __kmalloc+0x711/0x8a0 [] jffs2_sum_init+0xd9/0x1a0 [] jffs2_do_mount_fs+0x745/0x2120 [] jffs2_do_fill_super+0x35c/0x810 [] jffs2_fill_super+0x2b9/0x3b0 [...] -------------------------------------------- This is because the resources allocated in jffs2_sum_init() are not released. Call jffs2_sum_exit() to release these resources to solve the problem. Fixes: e631ddba5887 ("[JFFS2] Add erase block summary support (mount time improvement)") Signed-off-by: Baokun Li Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin --- fs/jffs2/fs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index b7df9e34ccfd..dd7c6fbd2cc5 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c @@ -598,6 +598,7 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent) jffs2_free_raw_node_refs(c); kvfree(c->blocks); jffs2_clear_xattr_subsystem(c); + jffs2_sum_exit(c); out_inohash: kfree(c->inocache_list); out_wbuf: -- 2.35.1