BUG/MINOR: pools: fix a possible memory leak in the lockless pool_flush()
The lockless version of pool_flush() had a leftover of the original version causing the pool's first entry to be set to NULL at the end. The problem is that it does this outside of any lock and in a non- atomic way, so that any concurrent alloc+free would result in a lost object. The risk is low and the consequence even lower, given that pool_flush() is only used in pool_destroy() (hence single-threaded) or by stream_free() during a soft-stop (not the place where most allocations happen), so in the worst case it could result in valgrind complaining on soft-stop. The bug was introduced with the first version of the code, in 1.9, so the fix can be backported to all stable versions.
This commit is contained in:
parent
efbf35caf9
commit
c239cde26f
@ -303,8 +303,7 @@ void pool_flush(struct pool_head *pool)
|
||||
next = *POOL_LINK(pool, temp);
|
||||
pool_put_to_os(pool, temp);
|
||||
}
|
||||
pool->free_list = next;
|
||||
/* here, we should have pool->allocate == pool->used */
|
||||
/* here, we should have pool->allocated == pool->used */
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user