Skip to content

Commit e667137

Browse files
zhangjiarangregkh
authored andcommitted
RDMA/hns: Solve the overflow of the calc_pg_sz()
[ Upstream commit 768202a ] calc_pg_sz() may gets a data calculation overflow if the PAGE_SIZE is 64 KB and hop_num is 2. It is because that all variables involved in calculation are defined in type of int. So change the type of bt_chunk_size, buf_chunk_size and obj_per_chunk_default to u64. Fixes: ba6bb7e ("RDMA/hns: Add interfaces to get pf capabilities from firmware") Link: https://lore.kernel.org/r/1600509802-44382-6-git-send-email-liweihang@huawei.com Signed-off-by: Jiaran Zhang <zhangjiaran@huawei.com> Signed-off-by: Weihang Li <liweihang@huawei.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f5d5921 commit e667137

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/infiniband/hw/hns/hns_roce_hw_v2.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,9 +1770,9 @@ static void calc_pg_sz(int obj_num, int obj_size, int hop_num, int ctx_bt_num,
17701770
int *buf_page_size, int *bt_page_size, u32 hem_type)
17711771
{
17721772
u64 obj_per_chunk;
1773-
int bt_chunk_size = 1 << PAGE_SHIFT;
1774-
int buf_chunk_size = 1 << PAGE_SHIFT;
1775-
int obj_per_chunk_default = buf_chunk_size / obj_size;
1773+
u64 bt_chunk_size = PAGE_SIZE;
1774+
u64 buf_chunk_size = PAGE_SIZE;
1775+
u64 obj_per_chunk_default = buf_chunk_size / obj_size;
17761776

17771777
*buf_page_size = 0;
17781778
*bt_page_size = 0;

0 commit comments

Comments
 (0)