Commit 3144533b authored by Dennis Dalessandro's avatar Dennis Dalessandro Committed by Jason Gunthorpe

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: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 15b796bc
...@@ -351,6 +351,7 @@ static uint32_t opa_vnic_get_dlid(struct opa_vnic_adapter *adapter, ...@@ -351,6 +351,7 @@ static uint32_t opa_vnic_get_dlid(struct opa_vnic_adapter *adapter,
if (unlikely(!dlid)) if (unlikely(!dlid))
v_warn("Null dlid in MAC address\n"); v_warn("Null dlid in MAC address\n");
} else if (def_port != OPA_VNIC_INVALID_PORT) { } else if (def_port != OPA_VNIC_INVALID_PORT) {
if (def_port < OPA_VESW_MAX_NUM_DEF_PORT)
dlid = info->vesw.u_ucast_dlid[def_port]; dlid = info->vesw.u_ucast_dlid[def_port];
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment