mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-03-10 00:00:04 +03:00
Make sure aligned_alloc size is a multiply of alignment
Fix a ASan complaint. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
6a765fd085
commit
f3fdbbfa92
@ -20,9 +20,11 @@ static inline void *kmalloc(size_t size, gfp_t flags)
|
||||
|
||||
run_shrinkers();
|
||||
|
||||
size_t alignment = min(rounddown_pow_of_two(size),
|
||||
(size_t)PAGE_SIZE);
|
||||
size = roundup(size, alignment);
|
||||
p = size
|
||||
? aligned_alloc(min(rounddown_pow_of_two(size),
|
||||
(size_t)PAGE_SIZE), size)
|
||||
? aligned_alloc(alignment, size)
|
||||
: malloc(0);
|
||||
if (p && (flags & __GFP_ZERO))
|
||||
memset(p, 0, size);
|
||||
|
Loading…
Reference in New Issue
Block a user