From: niam <niam.niam@gmail.com>
To: Joakim Tjernlund <joakim.tjernlund@transmode.se>
Cc: David Woodhouse <dwmw2@infradead.org>,
Joe Perches <joe@perches.com>,
linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org,
Michael Trimarchi <trimarchi@gandalf.sssup.it>
Subject: Re: [PATCH] jffs2: fix memory leak if the sector was successfully erased
Date: Mon, 22 Feb 2010 19:57:29 +0200 [thread overview]
Message-ID: <a9e22dff1002220957r469ea79cg38309ffd24c19644@mail.gmail.com> (raw)
In-Reply-To: <OFB51E93AB.187F855F-ONC12576D2.00618F62-C12576D2.0061DEB5@transmode.se>
Yes, you are right.
Michael Trimarchi also responded that it's freed by the callback.
My concern now that it's not obvious to free erase instruction in
jffs2_erase_callback.
Why not to free it the same piece of code where it was allocated?
--Dima
On Mon, Feb 22, 2010 at 7:49 PM, Joakim Tjernlund
<joakim.tjernlund@transmode.se> wrote:
> niam <niam.niam@gmail.com> wrote on 2010/02/22 17:40:11:
>>
>> Resending patch to proper people/mailing list.
>>
>> Memory allocated for erase instruction is not freed if the sector was
>> successfully erased.
>
> NAK, jffs2_erase_callback() will free it so
> you have added a double free I think. Did you measure a memory leak?
>
>>
>> Signed-off-by: Dmytro Milinevskyy <niam.niam@gmail.com>
>> ---
>> fs/jffs2/erase.c | 4 +++-
>> 1 files changed, 3 insertions(+), 1 deletions(-)
>>
>> diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
>> index b47679b..c0a5604 100644
>> --- a/fs/jffs2/erase.c
>> +++ b/fs/jffs2/erase.c
>> @@ -74,8 +74,10 @@ static void jffs2_erase_block(struct jffs2_sb_info *c,
>> ((struct erase_priv_struct *)instr->priv)->c = c;
>>
>> ret = c->mtd->erase(c->mtd, instr);
>> - if (!ret)
>> + if (!ret) {
>> + kfree(instr);
>> return;
>> + }
>>
>> bad_offset = instr->fail_addr;
>> kfree(instr);
>>
>
>
prev parent reply other threads:[~2010-02-22 17:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <a9e22dff1002220826p63209a33n27e84ea10e191a19@mail.gmail.com>
2010-02-22 16:40 ` niam
2010-02-22 17:49 ` Joakim Tjernlund
2010-02-22 17:57 ` niam [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=a9e22dff1002220957r469ea79cg38309ffd24c19644@mail.gmail.com \
--to=niam.niam@gmail.com \
--cc=dwmw2@infradead.org \
--cc=joakim.tjernlund@transmode.se \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=trimarchi@gandalf.sssup.it \
/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
all inboxes | Powered by JetHome®