From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 525C7C433F5 for ; Mon, 23 May 2022 06:00:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229825AbiEWGAk (ORCPT ); Mon, 23 May 2022 02:00:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229634AbiEWGA0 (ORCPT ); Mon, 23 May 2022 02:00:26 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96EB3340C2 for ; Sun, 22 May 2022 23:00:24 -0700 (PDT) Received: from dggpeml500020.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4L668Z2CpDzgY8H; Mon, 23 May 2022 13:58:54 +0800 (CST) Received: from [10.174.177.174] (10.174.177.174) by dggpeml500020.china.huawei.com (7.185.36.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 23 May 2022 14:00:21 +0800 Message-ID: Date: Mon, 23 May 2022 14:00:21 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH -next] jffs2: fix memory leak in jffs2_do_fill_super To: , , , CC: , Baokun Li References: <20220412093816.2280678-1-libaokun1@huawei.com> From: "libaokun (A)" In-Reply-To: <20220412093816.2280678-1-libaokun1@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.177.174] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500020.china.huawei.com (7.185.36.88) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ping 在 2022/4/12 17:38, Baokun Li 写道: > 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 > --- > fs/jffs2/fs.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c > index 71f03a5d36ed..f83a468b6488 100644 > --- a/fs/jffs2/fs.c > +++ b/fs/jffs2/fs.c > @@ -604,6 +604,7 @@ int jffs2_do_fill_super(struct super_block *sb, struct fs_context *fc) > 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: