Re: [PATCH v2 for-next 6/9] RDMA/hns: Solve the overflow of the calc_pg_sz()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Sep 09, 2020 at 04:57:31PM +0800, Weihang Li wrote:
> From: Jiaran Zhang <zhangjiaran@xxxxxxxxxx>
> 
> 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: ba6bb7e97421 ("RDMA/hns: Add interfaces to get pf capabilities from firmware")
> Signed-off-by: Jiaran Zhang <zhangjiaran@xxxxxxxxxx>
> Signed-off-by: Weihang Li <liweihang@xxxxxxxxxx>
>  drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> index 01aabb7..af2dea1 100644
> +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> @@ -1804,9 +1804,9 @@ static void calc_pg_sz(int obj_num, int obj_size, int hop_num, int ctx_bt_num,
>  		       int *buf_page_size, int *bt_page_size, u32 hem_type)
>  {
>  	u64 obj_per_chunk;
> -	int bt_chunk_size = 1 << PAGE_SHIFT;
> -	int buf_chunk_size = 1 << PAGE_SHIFT;
> -	int obj_per_chunk_default = buf_chunk_size / obj_size;
> +	u64 bt_chunk_size = 1 << PAGE_SHIFT;
> +	u64 buf_chunk_size = 1 << PAGE_SHIFT;

This is PAGE_SIZE

Jason



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux