From: Akinobu Mita Date: Thu, 18 Oct 2007 10:05:11 +0000 (-0700) Subject: cpu hotplug: slab: fix memory leak in cpu hotplug error path X-Git-Tag: v2.6.24-rc1~410 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12d00f6a121877235a5cacc56386936dd9bb81af;p=linux-2.6 cpu hotplug: slab: fix memory leak in cpu hotplug error path 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 Cc: Gautham R Shenoy Acked-by: Pekka Enberg Signed-off-by: Akinobu Mita Cc: Gautham R Shenoy Cc: Oleg Nesterov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/slab.c b/mm/slab.c index 671588497e..54eb555c4e 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -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]; @@ -1315,6 +1320,7 @@ static int __cpuinit cpuup_prepare(long cpu) } return 0; bad: + cpuup_canceled(cpu); return -ENOMEM; }