fix memory leak in mm/slab.c::alloc_kmemlist()
PATCH 1/1 fix memory leak in mm/slab.c::alloc_kmemlist()
The Coverity checker found that we may leak memory in mm/slab.c::alloc_kmemlist()
This should fix the leak and coverity bug #589
---
mm/slab.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletion(-)
mm/slab.c +3 -1
@@ -3366,8 +3366,10 @@ static int alloc_kmemlist(struct kmem_cacontinue ; }if (!(l3 =kmalloc_node (sizeof (struct kmem_list3 ), -GFP_KERNEL , node))) +GFP_KERNEL , node))) { +kfree (new); goto fail; + }kmem_list3_init (l3); l3->next_reap = jiffies + REAPTIMEOUT_LIST3 +
Quoted 17 lines · Jesper Juhl
The Coverity checker found that we may leak memory in mm/slab.c::alloc_kmemlist()
This should fix the leak and coverity bug #589Signed-off-by Jesper Juhl <[email protected]>---
mm/slab.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletion(-)mm/slab.c +0
-0@@ -3366,8 +3366,10 @@ static int alloc_kmemlist(struct kmem_cacontinue ;
mm/slab.c static int alloc_kmemlist(struct kmem_ca · line 3375
Quoted 10 lines
mm/slab.c +3
-1}if (!(l3 =kmalloc_node (sizeof (struct kmem_list3 ), -GFP_KERNEL , node))) +GFP_KERNEL , node))) { +kfree (new); goto fail; + }kmem_list3_init (l3); l3->next_reap = jiffies + REAPTIMEOUT_LIST3 +
It's more complicated than that. We can also leak new_alien. And if any allocation in that for_each_online_node() loop fails I guess we need to back out all the allocations we've done thus far, which means another loop. ug.
Patches against rc6-mm1 would be preferred please, that code's changed quite a bit.
Quoted 7 lines · Andrew Morton
Quoted 6 lines · Jesper Juhl
The Coverity checker found that we may leak memory in mm/slab.c::alloc_kmemlist()
This should fix the leak and coverity bug #589
[snip]
Quoted 6 lines
It's more complicated than that. We can also leak
new_alien. And if any allocation in thatfor_each_online_node()loop fails I guess we need to back out all the allocations we've done thus far, which means another loop. ug.
Ok, I'll take a second (and much more thorough) look at it tonight. And I'll be sure to describe whatever changes I make and the reasoning behind.
Quoted 3 lines
Patches against rc6-mm1 would be preferred please, that code's changed quite a bit.
Sure thing.
--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
Quoted 20 lines · Jesper Juhl
Quoted 7 lines · Andrew Morton
Quoted 6 lines · Jesper Juhl
The Coverity checker found that we may leak memory in mm/slab.c::alloc_kmemlist()
This should fix the leak and coverity bug #589[snip]
Quoted 6 lines
It's more complicated than that. We can also leak
new_alien. And if any allocation in thatfor_each_online_node()loop fails I guess we need to back out all the allocations we've done thus far, which means another loop. ug.Ok, I'll take a second (and much more thorough) look at it tonight. And I'll be sure to describe whatever changes I make and the reasoning behind.
Quoted 5 lines
Quoted 3 lines
Patches against rc6-mm1 would be preferred please, that code's changed quite a bit.
Sure thing.
Ok, I've been playing around with a few ways to resolve this, but I'm a bit pressed for time and won't have properly tested patches ready tonight. I will however keep at this, so you'll see patches releatively shortly, just give me another day or two and I'll have this fixed in a nice way (nice little task to work at :) ...
--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
Quoted 5 lines · Jesper Juhl
Ok, I've been playing around with a few ways to resolve this, but I'm a bit pressed for time and won't have properly tested patches ready tonight. I will however keep at this, so you'll see patches releatively shortly, just give me another day or two and I'll have this fixed in a nice way (nice little task to work at :) ...
Maybe extract a alloc_kmemlist_node and free_kmemlist_node from alloc_kmemlist()? It gets a bit complicated if all of this is handled within alloc_kmemlist and having these separate may simplify recovery on out of memory.
Quoted 8 lines · Christoph Lameter
Quoted 5 lines · Jesper Juhl
Ok, I've been playing around with a few ways to resolve this, but I'm a bit pressed for time and won't have properly tested patches ready tonight. I will however keep at this, so you'll see patches releatively shortly, just give me another day or two and I'll have this fixed in a nice way (nice little task to work at :) ...
Quoted 5 lines
Maybe extract a
alloc_kmemlist_nodeandfree_kmemlist_nodefromalloc_kmemlist()? It gets a bit complicated if all of this is handled withinalloc_kmemlistand having these separate may simplify recovery on out of memory.
Nice Idea. So far I've been trying to handle it all inside the function, but maybe sepperating stuff out might simplify it.. anyway, i'll keep working on this and will submit patches in a day or two... It really is a nice little problem to work on and I'll find a solution for it (well, I already have at least one, but it's ugly as hell, want to find a better one) - gimme a few days.
--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html