[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181225015701.6289-1-sjhuang@iluvatar.ai>
Date: Tue, 25 Dec 2018 09:57:01 +0800
From: Huang Shijie <sjhuang@...vatar.ai>
To: <akpm@...ux-foundation.org>
CC: <sfr@...b.auug.org.au>, <alexey.skidanov@...el.com>,
<linux-kernel@...r.kernel.org>, <shijie8@...il.com>,
Huang Shijie <sjhuang@...vatar.ai>
Subject: [PATCH 1/2 fix] lib/genalloc.c: Use the vzalloc_node to allocate the bitmap.
Some devices may have big memory on chip, such as over 1G.
In some cases, the nbytes maybe bigger then 4M which is the bounday of
the memory buddy system (4K default).
So use vzalloc_node() to allocate the bitmap.
Also use vfree to free the it.
Signed-off-by: Huang Shijie <sjhuang@...vatar.ai>
---
The v1 did not free the memory with vfree.
This patch fixes it.
---
lib/genalloc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/genalloc.c b/lib/genalloc.c
index 5deb25c40a5a..f365d71cdc77 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -187,7 +187,7 @@ int gen_pool_add_virt(struct gen_pool *pool, unsigned long virt, phys_addr_t phy
int nbytes = sizeof(struct gen_pool_chunk) +
BITS_TO_LONGS(nbits) * sizeof(long);
- chunk = kzalloc_node(nbytes, GFP_KERNEL, nid);
+ chunk = vzalloc_node(nbytes, nid);
if (unlikely(chunk == NULL))
return -ENOMEM;
@@ -251,7 +251,7 @@ void gen_pool_destroy(struct gen_pool *pool)
bit = find_next_bit(chunk->bits, end_bit, 0);
BUG_ON(bit < end_bit);
- kfree(chunk);
+ vfree(chunk);
}
kfree_const(pool->name);
kfree(pool);
--
2.17.1
Powered by blists - more mailing lists