Skip to content

Commit

Permalink
IB/hfi1: Ensure ucast_dlid access doesnt exceed bounds
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dennis Dalessandro authored and Jason Gunthorpe committed Oct 1, 2018
1 parent 15b796b commit 3144533
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/infiniband/ulp/opa_vnic/opa_vnic_encap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}

Expand Down

0 comments on commit 3144533

Please sign in to comment.