public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: cuigaosheng <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: Thu, 18 Aug 2022 08:59:27 +0200 (CEST)	[thread overview]
Message-ID: <1160016027.119085.1660805967979.JavaMail.zimbra@nod.at> (raw)
In-Reply-To: <6733eee6-bfb6-7ee9-1331-2a739520fcd5@huawei.com>

----- 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-18  7:00 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 [this message]
2022-08-19  2:37     ` cuigaosheng

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=1160016027.119085.1660805967979.JavaMail.zimbra@nod.at \
    --to=richard@nod.at \
    --cc=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=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