Skip to content

Commit 0dc2d6f

Browse files
tatyana-enjgunthorpe
authored andcommitted
RDMA/irdma: Check vsi pointer before using it
Fix a coverity warning about NULL pointer dereference: Dereferencing "vsi", which is known to be "NULL". Link: https://lore.kernel.org/r/[email protected] Reported-by: coverity-bot <[email protected]> Addresses-Coverity-ID: 1505164 ("Null pointer dereferences") Fixes: 8498a30 ("RDMA/irdma: Register auxiliary driver and implement private channel OPs") Signed-off-by: Mustafa Ismail <[email protected]> Signed-off-by: Tatyana Nikolova <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent b18c7da commit 0dc2d6f

File tree

1 file changed

+6
-3
lines changed
  • drivers/infiniband/hw/irdma

1 file changed

+6
-3
lines changed

drivers/infiniband/hw/irdma/main.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,10 @@ static void irdma_remove(struct auxiliary_device *aux_dev)
215215
pr_debug("INIT: Gen2 PF[%d] device remove success\n", PCI_FUNC(pf->pdev->devfn));
216216
}
217217

218-
static void irdma_fill_device_info(struct irdma_device *iwdev, struct ice_pf *pf)
218+
static void irdma_fill_device_info(struct irdma_device *iwdev, struct ice_pf *pf,
219+
struct ice_vsi *vsi)
219220
{
220221
struct irdma_pci_f *rf = iwdev->rf;
221-
struct ice_vsi *vsi = ice_get_main_vsi(pf);
222222

223223
rf->cdev = pf;
224224
rf->gen_ops.register_qset = irdma_lan_register_qset;
@@ -253,12 +253,15 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
253253
struct iidc_auxiliary_dev,
254254
adev);
255255
struct ice_pf *pf = iidc_adev->pf;
256+
struct ice_vsi *vsi = ice_get_main_vsi(pf);
256257
struct iidc_qos_params qos_info = {};
257258
struct irdma_device *iwdev;
258259
struct irdma_pci_f *rf;
259260
struct irdma_l2params l2params = {};
260261
int err;
261262

263+
if (!vsi)
264+
return -EIO;
262265
iwdev = ib_alloc_device(irdma_device, ibdev);
263266
if (!iwdev)
264267
return -ENOMEM;
@@ -268,7 +271,7 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
268271
return -ENOMEM;
269272
}
270273

271-
irdma_fill_device_info(iwdev, pf);
274+
irdma_fill_device_info(iwdev, pf, vsi);
272275
rf = iwdev->rf;
273276

274277
if (irdma_ctrl_init_hw(rf)) {

0 commit comments

Comments
 (0)