linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: cuigaosheng <cuigaosheng1@huawei.com>
To: Richard Weinberger <richard@nod.at>, <cuigaosheng1@huawei.com>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	linux-mtd <linux-mtd@lists.infradead.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	<gongruiqi1@huawei.com>, <wangweiyang2@huawei.com>
Subject: Re: [PATCH -next] mtd/ftl: Fix memleak in ftl_add_mtd()
Date: Fri, 19 Aug 2022 10:37:22 +0800	[thread overview]
Message-ID: <df18397e-bcbe-7d3b-d316-5f22dd4cff9b@huawei.com> (raw)
In-Reply-To: <1160016027.119085.1660805967979.JavaMail.zimbra@nod.at>

> There seems to be a problem with your caps lock key. ;-)

I wil adjust my caps lock key, Thanks for reminding.

> Is this leak observable via kmemleak or such?
> I always thought ->remove_dev() unconditionally do a cleanup later.

When I'm working on other issues with mtd,I needed to analyze the mtd driver
initialization process,during reading the code, refer to other driver
implementation,I found this problem, not kmemleak. Thanks.

在 2022/8/18 14:59, Richard Weinberger 写道:
> ----- Ursprüngliche Mail -----
>> Von: "cuigaosheng" <cuigaosheng1@huawei.com>
>>
>> PING
> There seems to be a problem with your caps lock key. ;-)
>   
>> 在 2022/7/15 15:11, Gaosheng Cui 写道:
>>> When add_mtd_blktrans_dev failed, partition's memory will be freed
>>> by kfree, but there are some structure members that are allocated
>>> for memory independently, such as partition->VirtualBlockMap,
>>> partition->EUNInfo, partition->ZferInfo, and partition->bam_cache,
>>> so kfree(partition) may cause memory leaks, using ftl_freepart(partition)
>>> will fix it.
> Is this leak observable via kmemleak or such?
> I always thought ->remove_dev() unconditionally do a cleanup later.
>
>>> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
>>> Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
>>> ---
>>>    drivers/mtd/ftl.c | 1 +
>>>    1 file changed, 1 insertion(+)
>>>
>>> diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c
>>> index f655d2905270..200271bdc7aa 100644
>>> --- a/drivers/mtd/ftl.c
>>> +++ b/drivers/mtd/ftl.c
>>> @@ -1031,6 +1031,7 @@ static void ftl_add_mtd(struct mtd_blktrans_ops *tr,
>>> struct mtd_info *mtd)
>>>    		partition->mbd.devnum = -1;
>>>    		if (!add_mtd_blktrans_dev(&partition->mbd))
>>>    			return;
>>> +		ftl_freepart(partition);
>>>    	}
>>>    
>>>    	kfree(partition);
> .

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

      reply	other threads:[~2022-08-19  2:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-15  7:11 [PATCH -next] mtd/ftl: Fix memleak in ftl_add_mtd() Gaosheng Cui
2022-08-18  1:31 ` cuigaosheng
2022-08-18  6:59   ` Richard Weinberger
2022-08-19  2:37     ` cuigaosheng [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=df18397e-bcbe-7d3b-d316-5f22dd4cff9b@huawei.com \
    --to=cuigaosheng1@huawei.com \
    --cc=gongruiqi1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.com \
    --cc=wangweiyang2@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).