mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
bpf: Fix off-by-one error in bpf_mem_cache_idx()
[ Upstream commit36024d023d] According to the definition of sizes[NUM_CACHES], when the size passed to bpf_mem_cache_size() is 256, it should return 6 instead 7. Fixes:7c8199e24f("bpf: Introduce any context BPF specific memory allocator.") Signed-off-by: Hou Tao <houtao1@huawei.com> Acked-by: Yonghong Song <yhs@fb.com> Link: https://lore.kernel.org/r/20230118084630.3750680-1-houtao@huaweicloud.com Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
ba32923bce
commit
c32efcf9ff
@@ -71,7 +71,7 @@ static int bpf_mem_cache_idx(size_t size)
|
||||
if (size <= 192)
|
||||
return size_index[(size - 1) / 8] - 1;
|
||||
|
||||
return fls(size - 1) - 1;
|
||||
return fls(size - 1) - 2;
|
||||
}
|
||||
|
||||
#define NUM_CACHES 11
|
||||
|
||||
Reference in New Issue
Block a user