提交 36024d02 编写于 作者: H Hou Tao 提交者: Alexei Starovoitov

bpf: Fix off-by-one error in bpf_mem_cache_idx()

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: 7c8199e2 ("bpf: Introduce any context BPF specific memory allocator.")
Signed-off-by: NHou Tao <houtao1@huawei.com>
Acked-by: NYonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/r/20230118084630.3750680-1-houtao@huaweicloud.comSigned-off-by: NAlexei Starovoitov <ast@kernel.org>
上级 b9fb10d1
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册