Re: [PATCH for-next 7/9] RDMA/hns: Prevent the gid overflow

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

 



On Fri, Feb 22, 2019 at 12:21:06PM +0800, Lijun Ou wrote:
> Because hip08 supports up to 256 gids and hip06 supports up to 2 gids, it
> adds judgement for preventing the gid overflow.
> 
> Signed-off-by: Lijun Ou <oulijun@xxxxxxxxxx>
>  drivers/infiniband/hw/hns/hns_roce_main.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c
> index 29fb4fb..e3f79d1 100644
> +++ b/drivers/infiniband/hw/hns/hns_roce_main.c
> @@ -81,8 +81,12 @@ static int hns_roce_add_gid(const struct ib_gid_attr *attr, void **context)
>  	unsigned long flags;
>  	int ret;
>  
> -	if (port >= hr_dev->caps.num_ports)
> +	if (port >= hr_dev->caps.num_ports ||
> +	    attr->index > hr_dev->caps.gid_table_len[port]) {
> +		dev_err(hr_dev->dev, "add gid failed. port - %d, index - %d\n",
> +			port, attr->index);
>  		return -EINVAL;
> +	}

The core code already checks these values, drivers should not
duplicate core checks. 

Drop these tests and make sure that
ib_dev->port_data[rdma_port].immutable.gid_tbl_len is right.

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