2010-06-05 12:12:16

by Imre Deak

[permalink] [raw]
Subject: [PATCH] genalloc: fix allocation from end of pool

From: Imre Deak <[email protected]>

bitmap_find_next_zero_area requires the size of the bitmap, we instead
passed the last suitable position. This made it impossible to allocate
from the end of the pool.

Signed-off-by: Imre Deak <[email protected]>
CC: Andrew Morton <[email protected]>
CC: Zygo Blaxell <[email protected]>
CC: Tejun Heo <[email protected]>
CC: Akinobu Mita <[email protected]>

---
lib/genalloc.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/lib/genalloc.c b/lib/genalloc.c
index 736c3b0..1923f14 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -128,7 +128,6 @@ unsigned long gen_pool_alloc(struct gen_pool *pool, size_t size)
chunk = list_entry(_chunk, struct gen_pool_chunk, next_chunk);

end_bit = (chunk->end_addr - chunk->start_addr) >> order;
- end_bit -= nbits + 1;

spin_lock_irqsave(&chunk->lock, flags);
start_bit = bitmap_find_next_zero_area(chunk->bits, end_bit, 0,
--
1.7.1


2010-06-07 01:18:48

by Akinobu Mita

[permalink] [raw]
Subject: Re: [PATCH] genalloc: fix allocation from end of pool

2010/6/5 <[email protected]>:
> From: Imre Deak <[email protected]>
>
> bitmap_find_next_zero_area requires the size of the bitmap, we instead
> passed the last suitable position. This made it impossible to allocate
> from the end of the pool.

Looks good to me.
This bug was introduced by commit 243797f59b748f679ab88d456fcc4f92236d724b
("genalloc: use bitmap_find_next_zero_area")

> Signed-off-by: Imre Deak <[email protected]>
> CC: Andrew Morton <[email protected]>
> CC: Zygo Blaxell <[email protected]>
> CC: Tejun Heo <[email protected]>
> CC: Akinobu Mita <[email protected]>
>
> ---
> ?lib/genalloc.c | ? ?1 -
> ?1 files changed, 0 insertions(+), 1 deletions(-)
>
> diff --git a/lib/genalloc.c b/lib/genalloc.c
> index 736c3b0..1923f14 100644
> --- a/lib/genalloc.c
> +++ b/lib/genalloc.c
> @@ -128,7 +128,6 @@ unsigned long gen_pool_alloc(struct gen_pool *pool, size_t size)
> ? ? ? ? ? ? ? ?chunk = list_entry(_chunk, struct gen_pool_chunk, next_chunk);
>
> ? ? ? ? ? ? ? ?end_bit = (chunk->end_addr - chunk->start_addr) >> order;
> - ? ? ? ? ? ? ? end_bit -= nbits + 1;
>
> ? ? ? ? ? ? ? ?spin_lock_irqsave(&chunk->lock, flags);
> ? ? ? ? ? ? ? ?start_bit = bitmap_find_next_zero_area(chunk->bits, end_bit, 0,
> --
> 1.7.1
>
>