mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] jffs2: fix memory leak if the sector was successfully erased
       [not found] <a9e22dff1002220826p63209a33n27e84ea10e191a19@mail.gmail.com>
@ 2010-02-22 16:40 ` niam
  2010-02-22 17:49   ` Joakim Tjernlund
  0 siblings, 1 reply; 3+ messages in thread
From: niam @ 2010-02-22 16:40 UTC (permalink / raw)
  To: David Woodhouse, Joe Perches, Joakim Tjernlund, linux-mtd; +Cc: linux-kernel

Resending patch to proper people/mailing list.

Memory allocated for erase instruction is not freed if the sector was
successfully erased.

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);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] jffs2: fix memory leak if the sector was successfully erased
  2010-02-22 16:40 ` [PATCH] jffs2: fix memory leak if the sector was successfully erased niam
@ 2010-02-22 17:49   ` Joakim Tjernlund
  2010-02-22 17:57     ` niam
  0 siblings, 1 reply; 3+ messages in thread
From: Joakim Tjernlund @ 2010-02-22 17:49 UTC (permalink / raw)
  To: niam; +Cc: David Woodhouse, Joe Perches, linux-kernel, linux-mtd

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);
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] jffs2: fix memory leak if the sector was successfully  erased
  2010-02-22 17:49   ` Joakim Tjernlund
@ 2010-02-22 17:57     ` niam
  0 siblings, 0 replies; 3+ messages in thread
From: niam @ 2010-02-22 17:57 UTC (permalink / raw)
  To: Joakim Tjernlund
  Cc: David Woodhouse, Joe Perches, linux-kernel, linux-mtd, Michael Trimarchi

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);
>>
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-02-22 18:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <a9e22dff1002220826p63209a33n27e84ea10e191a19@mail.gmail.com>
2010-02-22 16:40 ` [PATCH] jffs2: fix memory leak if the sector was successfully erased niam
2010-02-22 17:49   ` Joakim Tjernlund
2010-02-22 17:57     ` niam

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®