aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSunil Khatri <sunilkh@codeaurora.org>2014-02-13 19:52:09 +0530
committerMoyster <oysterized@gmail.com>2018-11-29 15:21:43 +0100
commit2b6e2f96190f607e7887d7a7bdc93c21d91b6700 (patch)
treec7fac82dd3c84251818a82fcad22e2e90377a0fc /lib
parent666bda46d733bc4a3f6ff72b3589ccbdd0be3fc4 (diff)
genalloc: Correct nbytes calculation on long boundary
In existing code we calculate nbytes based on the byte boundary, but genalloc uses bitmap for maintaining the memory allocation aligned to long. So while calculating nbytes we end up getting wrong nbytes. example: lets say nbytes comes to 9 bytes for 70 bits when bytes aligned,but if long aligned we will have 3 long words i.e 12 bytes. This difference may lead to choosing the wrong api for freeing the memory i.e Between kfree() and vfree(). Fix was inspired by an upstream commit eedce141cd2dad8d0cefc5468ef41898949a7031, bringing same fix into the gen_pool_detroy path. Change-Id: I942caf59e25515c780896b328b912604df9e10bf Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org> Signed-off-by: Sunil Khatri <sunilkh@codeaurora.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/genalloc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/genalloc.c b/lib/genalloc.c
index e4ac53328..78bdae05e 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -256,7 +256,7 @@ void gen_pool_destroy(struct gen_pool *pool)
end_bit = chunk_size(chunk) >> order;
nbytes = sizeof(struct gen_pool_chunk) +
- (end_bit + BITS_PER_BYTE - 1) / BITS_PER_BYTE;
+ BITS_TO_LONGS(end_bit) * sizeof(long);
bit = find_next_bit(chunk->bits, end_bit, 0);
BUG_ON(bit < end_bit);