* [PATCH] jffs2: fix memory leak if the sector was successfully erased
@ 2010-02-22 16:26 Ni@m
2010-02-22 16:33 ` Russell King - ARM Linux
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Ni@m @ 2010-02-22 16:26 UTC (permalink / raw)
To: linux-arm-kernel
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 related [flat|nested] 10+ messages in thread
* [PATCH] jffs2: fix memory leak if the sector was successfully erased
2010-02-22 16:26 [PATCH] jffs2: fix memory leak if the sector was successfully erased Ni@m
@ 2010-02-22 16:33 ` Russell King - ARM Linux
2010-02-22 16:35 ` Daniel Mack
2010-02-22 16:40 ` niam
2 siblings, 0 replies; 10+ messages in thread
From: Russell King - ARM Linux @ 2010-02-22 16:33 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Feb 22, 2010 at 06:26:22PM +0200, Ni at m wrote:
> Memory allocated for erase instruction is not freed if the sector was
> successfully erased.
I can not help you. Please direct your message to the jffs2 developers.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] jffs2: fix memory leak if the sector was successfully erased
2010-02-22 16:26 [PATCH] jffs2: fix memory leak if the sector was successfully erased Ni@m
2010-02-22 16:33 ` Russell King - ARM Linux
@ 2010-02-22 16:35 ` Daniel Mack
2010-02-22 17:28 ` Michael Trimarchi
2010-02-22 16:40 ` niam
2 siblings, 1 reply; 10+ messages in thread
From: Daniel Mack @ 2010-02-22 16:35 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Feb 22, 2010 at 06:26:22PM +0200, Ni at m wrote:
> Memory allocated for erase instruction is not freed if the sector was
> successfully erased.
>
> Signed-off-by: Dmytro Milinevskyy <niam.niam@gmail.com>
Can you forward that to the right people please? Call
scripts/get_maintainer.pl to get a list of maintainers.
Daniel
> ---
> 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);
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] jffs2: fix memory leak if the sector was successfully erased
2010-02-22 16:26 [PATCH] jffs2: fix memory leak if the sector was successfully erased Ni@m
2010-02-22 16:33 ` Russell King - ARM Linux
2010-02-22 16:35 ` Daniel Mack
@ 2010-02-22 16:40 ` niam
2010-02-22 17:49 ` Joakim Tjernlund
2 siblings, 1 reply; 10+ 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 related [flat|nested] 10+ messages in thread
* [PATCH] jffs2: fix memory leak if the sector was successfully erased
2010-02-22 16:35 ` Daniel Mack
@ 2010-02-22 17:28 ` Michael Trimarchi
2010-02-22 17:40 ` niam
0 siblings, 1 reply; 10+ messages in thread
From: Michael Trimarchi @ 2010-02-22 17:28 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
Daniel Mack wrote:
> On Mon, Feb 22, 2010 at 06:26:22PM +0200, Ni at m wrote:
>
>> Memory allocated for erase instruction is not freed if the sector was
>> successfully erased.
>>
>> Signed-off-by: Dmytro Milinevskyy <niam.niam@gmail.com>
>>
>
> Can you forward that to the right people please? Call
> scripts/get_maintainer.pl to get a list of maintainers.
>
> Daniel
>
>
>
>
>> ---
>> 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);
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel at lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>>
>
>
static void jffs2_erase_callback(struct erase_info *instr)
{
struct erase_priv_struct *priv = (void *)instr->priv;
if(instr->state != MTD_ERASE_DONE) {
printk(KERN_WARNING "Erase at 0x%08x finished, but state
!= MTD_ERASE_DONE. State is 0x%x instead.\n", instr->addr, instr->state);
jffs2_erase_failed(priv->c, priv->jeb, instr->fail_addr);
} else {
jffs2_erase_succeeded(priv->c, priv->jeb);
}
kfree(instr);
}
instr->callback = jffs2_erase_callback;
Maybe the free is here :)
Michael
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] jffs2: fix memory leak if the sector was successfully erased
2010-02-22 17:28 ` Michael Trimarchi
@ 2010-02-22 17:40 ` niam
0 siblings, 0 replies; 10+ messages in thread
From: niam @ 2010-02-22 17:40 UTC (permalink / raw)
To: linux-arm-kernel
Yes, indeed, you are right!
Thank you Michael!
Thank you to everybody and I'm sorry for doing that much noise here.
Next time I will try to send more correct patches.
However freeing memory in the callback is not obvious. Isn't better to
do this out of it?
-- Dima
On Mon, Feb 22, 2010 at 7:28 PM, Michael Trimarchi
<trimarchi@gandalf.sssup.it> wrote:
> Hi,
>
> Daniel Mack wrote:
>>
>> On Mon, Feb 22, 2010 at 06:26:22PM +0200, Ni at m wrote:
>>
>>>
>>> Memory allocated for erase instruction is not freed if the sector was
>>> successfully erased.
>>>
>>> Signed-off-by: Dmytro Milinevskyy <niam.niam@gmail.com>
>>>
>>
>> Can you forward that to the right people please? Call
>> scripts/get_maintainer.pl to get a list of maintainers.
>>
>> Daniel
>>
>>
>>
>>
>>>
>>> ---
>>> ?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);
>>>
>>> _______________________________________________
>>> linux-arm-kernel mailing list
>>> linux-arm-kernel at lists.infradead.org
>>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>>>
>>
>>
>
> static void jffs2_erase_callback(struct erase_info *instr)
> {
> ? ? ? struct erase_priv_struct *priv = (void *)instr->priv;
>
> ? ? ? if(instr->state != MTD_ERASE_DONE) {
> printk(KERN_WARNING "Erase at 0x%08x finished, but state != MTD_ERASE_DONE.
> State is 0x%x instead.\n", instr->addr, instr->state);
> ? ? ? ? ? ? ? jffs2_erase_failed(priv->c, priv->jeb, instr->fail_addr);
> ? ? ? } else {
> ? ? ? ? ? ? ? jffs2_erase_succeeded(priv->c, priv->jeb);
> ? ? ? }
> ? ? ? kfree(instr);
> }
>
> instr->callback = jffs2_erase_callback;
>
> Maybe the free is here ?:)
>
> Michael
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel at lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>>
>>
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] jffs2: fix memory leak if the sector was successfully erased
2010-02-22 16:40 ` niam
@ 2010-02-22 17:49 ` Joakim Tjernlund
0 siblings, 0 replies; 10+ messages in thread
From: Joakim Tjernlund @ 2010-02-22 17:49 UTC (permalink / raw)
To: niam; +Cc: Joe Perches, linux-mtd, David Woodhouse, linux-kernel
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] 10+ messages in thread
* Re: [PATCH] jffs2: fix memory leak if the sector was successfully erased
@ 2010-02-22 17:49 ` Joakim Tjernlund
0 siblings, 0 replies; 10+ 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] 10+ 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
-1 siblings, 0 replies; 10+ messages in thread
From: niam @ 2010-02-22 17:57 UTC (permalink / raw)
To: Joakim Tjernlund
Cc: Joe Perches, linux-mtd, David Woodhouse, linux-kernel,
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] 10+ messages in thread
* Re: [PATCH] jffs2: fix memory leak if the sector was successfully erased
@ 2010-02-22 17:57 ` niam
0 siblings, 0 replies; 10+ 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] 10+ messages in thread
end of thread, other threads:[~2010-02-22 18:02 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-22 16:26 [PATCH] jffs2: fix memory leak if the sector was successfully erased Ni@m
2010-02-22 16:33 ` Russell King - ARM Linux
2010-02-22 16:35 ` Daniel Mack
2010-02-22 17:28 ` Michael Trimarchi
2010-02-22 17:40 ` niam
2010-02-22 16:40 ` niam
2010-02-22 17:49 ` Joakim Tjernlund
2010-02-22 17:49 ` Joakim Tjernlund
2010-02-22 17:57 ` niam
2010-02-22 17:57 ` niam
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.