diff options
author | Dennis Dalessandro <dennis.dalessandro@intel.com> | 2018-09-26 20:55:53 +0300 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2018-10-01 04:21:12 +0300 |
commit | 3144533bf667c8e53bb20656b78295960073e57b (patch) | |
tree | 6fe22e4e9a524e1db802c354607e1ba2e9f20c17 /drivers/infiniband/ulp | |
parent | 15b796bc3d5cc8f776f5cb0770f9f3e8b282e4d1 (diff) | |
download | linux-3144533bf667c8e53bb20656b78295960073e57b.tar.xz |
IB/hfi1: Ensure ucast_dlid access doesnt exceed bounds
The dlid assignment made by looking into the u_ucast_dlid array does not
do an explicit check for the size of the array. The code path to arrive at
def_port, the index value is long and complicated so its best to just have
an explicit check here.
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/infiniband/ulp')
-rw-r--r-- | drivers/infiniband/ulp/opa_vnic/opa_vnic_encap.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/infiniband/ulp/opa_vnic/opa_vnic_encap.c b/drivers/infiniband/ulp/opa_vnic/opa_vnic_encap.c index 267da8215e08..31cd361416ac 100644 --- a/drivers/infiniband/ulp/opa_vnic/opa_vnic_encap.c +++ b/drivers/infiniband/ulp/opa_vnic/opa_vnic_encap.c @@ -351,7 +351,8 @@ static uint32_t opa_vnic_get_dlid(struct opa_vnic_adapter *adapter, if (unlikely(!dlid)) v_warn("Null dlid in MAC address\n"); } else if (def_port != OPA_VNIC_INVALID_PORT) { - dlid = info->vesw.u_ucast_dlid[def_port]; + if (def_port < OPA_VESW_MAX_NUM_DEF_PORT) + dlid = info->vesw.u_ucast_dlid[def_port]; } } |