jffs2: fix memory leak if the sector was successfully erased
PATCH 1/1 jffs2: fix memory leak if the sector was successfully erased
Memory allocated for erase instruction is not freed if the sector was successfully erased.
--- fs/jffs2/erase.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
fs/jffs2/erase.c +3 -1
@@ -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);
PATCH 1/1 jffs2: fix memory leak if the sector was successfully erased
Quoted 2 lines · Ni at m
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.
PATCH 1/1 jffs2: fix memory leak if the sector was successfully erased
In reply to Ni@mQuoted 4 lines · Ni at m
Memory allocated for erase instruction is not freed if the sector was successfully erased.
Signed-off-by Dmytro Milinevskyy <[email protected]>
Can you forward that to the right people please? Call scripts/get_maintainer.pl to get a list of maintainers.
Daniel
Quoted 25 lines
--- fs/jffs2/erase.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)fs/jffs2/erase.c +3
-1@@ -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
PATCH 1/1 jffs2: fix memory leak if the sector was successfully erased
Hi,
Quoted 34 lines · Daniel Mack
Quoted 5 lines · Ni at m
Memory allocated for erase instruction is not freed if the sector was successfully erased.
Signed-off-by Dmytro Milinevskyy <[email protected]>Can you forward that to the right people please? Call
scripts/get_maintainer.plto get a list of maintainers.Daniel
Quoted 18 lines
--- fs/jffs2/erase.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)fs/jffs2/erase.c +3
-1@@ -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 ; + }
Quoted 10 lines
Quoted 8 lines
fs/jffs2/erase.c +0
-0bad_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
Quoted 6 lines
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/1 jffs2: fix memory leak if the sector was successfully erased
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
Quoted 79 lines · Michael Trimarchi
Hi,
Quoted 37 lines · Daniel Mack
Quoted 6 lines · Ni at m
Memory allocated for erase instruction is not freed if the sector was successfully erased.
Signed-off-by Dmytro Milinevskyy <[email protected]>Can you forward that to the right people please? Call
scripts/get_maintainer.plto get a list of maintainers.Daniel
Quoted 19 lines
---
?fs/jffs2/erase.c | ? ?4 +++-
?1 files changed, 3 insertions(+), 1 deletions(-)fs/jffs2/erase.c +3
-1@@ -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; + ? ?}Quoted 10 lines
Quoted 8 lines
fs/jffs2/erase.c +0
-0? ? ? ?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-kernelstatic void
jffs2_erase_callback(struct erase_info *instr){
? ? ? structerase_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
Quoted 7 lines
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/1 jffs2: fix memory leak if the sector was successfully erased
In reply to Ni@mResending patch to proper people/mailing list.
Memory allocated for erase instruction is not freed if the sector was successfully erased.
---
fs/jffs2/erase.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
fs/jffs2/erase.c +0 -0
@@ -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);
Joakim Tjernlund
NAKniam <[email protected]> wrote on 2010/02/22 17:40:11:
Quoted 5 lines
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?
Quoted 23 lines
Signed-off-by Dmytro Milinevskyy <[email protected]>---
fs/jffs2/erase.c | 4 +++-1 files changed, 3 insertions(+), 1 deletions(-)fs/jffs2/erase.c +3
-1@@ -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);
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
Quoted 35 lines · Joakim Tjernlund
niam <[email protected]> wrote on 2010/02/22 17:40:11:
Quoted 5 lines
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?Quoted 23 lines
Signed-off-by Dmytro Milinevskyy <[email protected]>---
fs/jffs2/erase.c | 4 +++-1 files changed, 3 insertions(+), 1 deletions(-)fs/jffs2/erase.c +3
-1@@ -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);