Skip to content

Commit

Permalink
cpu hotplug: slab: fix memory leak in cpu hotplug error path
Browse files Browse the repository at this point in the history
This patch fixes memory leak in error path.

In reality, we don't need to call cpuup_canceled(cpu) for now.  But upcoming
cpu hotplug error handling change needs this.

Cc: Christoph Lameter <clameter@sgi.com>
Cc: Gautham R Shenoy <ego@in.ibm.com>
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Gautham R Shenoy <ego@in.ibm.com>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Akinobu Mita authored and Linus Torvalds committed Oct 18, 2007
1 parent fbf1e47 commit 12d00f6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mm/slab.c
Original file line number Diff line number Diff line change
Expand Up @@ -1282,13 +1282,18 @@ static int __cpuinit cpuup_prepare(long cpu)
shared = alloc_arraycache(node,
cachep->shared * cachep->batchcount,
0xbaadf00d);
if (!shared)
if (!shared) {
kfree(nc);
goto bad;
}
}
if (use_alien_caches) {
alien = alloc_alien_cache(node, cachep->limit);
if (!alien)
if (!alien) {
kfree(shared);
kfree(nc);
goto bad;
}
}
cachep->array[cpu] = nc;
l3 = cachep->nodelists[node];
Expand All @@ -1315,6 +1320,7 @@ static int __cpuinit cpuup_prepare(long cpu)
}
return 0;
bad:
cpuup_canceled(cpu);
return -ENOMEM;
}

Expand Down

0 comments on commit 12d00f6

Please sign in to comment.