RDMA/qedr: add null check before pointer dereference

Add null check before dereferencing pointer sgid_attr.ndev
inside function rdma_vlan_dev_vlan_id().

Addresses-Coverity-ID: 1373979
Signed-off-by: Gustavo A. R. Silva <[email protected]>
Acked-by: Ram Amrani <[email protected]>
Signed-off-by: Doug Ledford <[email protected]>
This commit is contained in:
Gustavo A. R. Silva 2017-05-22 13:30:15 -05:00 • committed by Doug Ledford
commit d38d7fdafa

View file

@ -270,11 +270,13 @@ static inline int qedr_gsi_build_header(struct qedr_dev *dev,
return rc;
}
vlan_id = rdma_vlan_dev_vlan_id(sgid_attr.ndev);
if (vlan_id < VLAN_CFI_MASK)
has_vlan = true;
if (sgid_attr.ndev)
if (sgid_attr.ndev) {
vlan_id = rdma_vlan_dev_vlan_id(sgid_attr.ndev);
if (vlan_id < VLAN_CFI_MASK)
has_vlan = true;
dev_put(sgid_attr.ndev);
}
if (!memcmp(&sgid, &zgid, sizeof(sgid))) {
DP_ERR(dev, "gsi post send: GID not found GID index %d\n",