2007-11-22 15:01:04

by Jerome Marchand

[permalink] [raw]
Subject: [PATCH] block: Fix memory leak in alloc_disk_node()

Fix a memory leak in alloc_disk_node(). Don't forget to free 'dkstats' when the allocation of 'part' failed.

Signed-off-by: Jerome Marchand <[email protected]>
---
genhd.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/block/genhd.c b/block/genhd.c
index e609996..f2ac914 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -715,6 +715,7 @@ struct gendisk *alloc_disk_node(int minors, int node_id)
disk->part = kmalloc_node(size,
GFP_KERNEL | __GFP_ZERO, node_id);
if (!disk->part) {
+ free_disk_stats(disk);
kfree(disk);
return NULL;
}


2007-11-23 08:17:49

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH] block: Fix memory leak in alloc_disk_node()

On Thu, Nov 22 2007, Jerome Marchand wrote:
> Fix a memory leak in alloc_disk_node(). Don't forget to free 'dkstats'
> when the allocation of 'part' failed.

Thanks, applied.

--
Jens Axboe