On Mon, 15 Jun 2009 17:30:32 -0500
Steve Wise <swise@xxxxxxxxxxxxxxxxxxxxx> wrote:
Andrew Morton wrote:
On Mon, 15 Jun 2009 23:35:31 +0200 (CEST)I seem to remember trying to get this removed a few years ago and the owner didn't want it removed...
Jiri Kosina <trivial@xxxxxxxxxx> wrote:
yep, I merged it, thanks.- write_lock(&pool->lock);Hi Zygo,
list_for_each_safe(_chunk, _next_chunk, &pool->chunks) {
chunk = list_entry(_chunk, struct gen_pool_chunk, next_chunk);
list_del(&chunk->next_chunk);
--
1.5.6.5
this doesn't really qualify for trivial tree, as it introduces a significant code change. Adding some CCs.
I wonder why drivers/infiniband/hw/cxgb3 users never noticed this.
void gen_pool_destroy(struct gen_pool *pool)
{
struct list_head *_chunk, *_next_chunk;
struct gen_pool_chunk *chunk;
int order = pool->min_alloc_order;
int bit, end_bit;
write_lock(&pool->lock);
list_for_each_safe(_chunk, _next_chunk, &pool->chunks) {
chunk = list_entry(_chunk, struct gen_pool_chunk, next_chunk);
list_del(&chunk->next_chunk);
end_bit = (chunk->end_addr - chunk->start_addr) >> order;
bit = find_next_bit(chunk->bits, end_bit, 0);
BUG_ON(bit < end_bit);
kfree(chunk);
}
kfree(pool);
return;
}
The write_lock is unneeded and wrong. Because if any other thread of
control is concurrently playing with this pool, it will sometimes do a
use-after-free.
So no other thread of control should have access to this pool, so
there's no need for the write_lock().