Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp443961iog; Mon, 13 Jun 2022 06:07:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLyGU8bUHUXu+Qq4V/Kl1vVX9w2NDjpdEolBi7r2WR7Q/kgRGIBtVqL4MuYPy/socMRVcB X-Received: by 2002:a63:89c1:0:b0:3fc:6001:e871 with SMTP id v184-20020a6389c1000000b003fc6001e871mr52602000pgd.14.1655125525725; Mon, 13 Jun 2022 06:05:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125525; cv=none; d=google.com; s=arc-20160816; b=QBjBzw0dIfpN/vK6zwHjvRLlIO7Fdstzz5bp20vK/QEjX9xrogyOYRShdUoQVIOWa3 gIsDY9CK5f2yT2mR7BqAKn6/fDnZsl1NHcjlE8bX1eL7Q5RdAEN9mWK30yazk4qH4EF4 xDS0u4m6tTRmQo7FJ9ZKP3vyOHHKW+E7vHuKHMwPZnfYgsDGkhic4zpUEvbvacuwc4wJ apPlUGXm/cZ6lsZfYnoJM2i39dFsy8JqSGIYVh7rOcY0M/o/NDrCN60Wr2CpJBYq3KEW tPwHIAD4R63kXuiAw3QcSv6JVyCedj6pUULM+xUelKaq5P1EjFvRB9KyuaSJPPIKkIp6 7OkA== 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=VxXxld+JbD5RphOj9KbtvCcVgNksC4lY3SPARKTKNtg=; b=vcjUFPEKIQ/v1JF2z45kZUy+qvwpu21csNOEr0Bt4YnHHFesxraA+klRNLdMbGWZ5y LsNxPqtW1++C/sNP5EFca2lQO6cYAjvMaRiV/39zYANtPQKZJaG+qDt4ywiTSrjDFnW9 lRMA/lo74sFDPVMOOY34UkDENhgbGGr43zGtQjl92C4oq6Lo18RjlOsVO9d8cT0iUaRp aui1ege1G3/hiD2HNbx/9FScWWaNoE5XEWQWitQOP//5eqdblhl0r5yoSx3P0ud1L4nN L6zgmyEkaNSxgHldpOWEIHxEp5gH6D0mttkosRWIhytJaWhLshICAWMytRF1ViHGF9UP 67LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vEJooU6s; 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 iw4-20020a170903044400b00153b2d1663csi9304126plb.580.2022.06.13.06.05.07; Mon, 13 Jun 2022 06:05:25 -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=vEJooU6s; 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 S244705AbiFMK1A (ORCPT + 99 others); Mon, 13 Jun 2022 06:27:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245613AbiFMKYo (ORCPT ); Mon, 13 Jun 2022 06:24:44 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23834205FD; Mon, 13 Jun 2022 03:19:14 -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 sin.source.kernel.org (Postfix) with ESMTPS id 76173CE110D; Mon, 13 Jun 2022 10:19:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F953C34114; Mon, 13 Jun 2022 10:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655115550; bh=C/1wgkfCoPY65kNeAyGytBp4GA2vjRzYayx29RryE+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vEJooU6sAU23InhpIhgpU2Yj+QVxDzG3gshBt4rNfvuDvXWkx/NBROeilN2Xc9zIl h2p2gzrbtraqxwWnDqdn3pTu//3cjdgGHSC6mJeqstZemYC0fKxEumUhj+ParL16w4 4yapYdSzU2gDZue/ZoixL6UWc5OZEfv3ussM11vM= 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.9 125/167] jffs2: fix memory leak in jffs2_do_fill_super Date: Mon, 13 Jun 2022 12:09:59 +0200 Message-Id: <20220613094910.147360722@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094840.720778945@linuxfoundation.org> References: <20220613094840.720778945@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 d3c9e4c82e57..610e11e76f2d 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c @@ -597,6 +597,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