Skip to content

Commit 1057afa

Browse files
YongjiXiemstsirkin
authored andcommitted
vDPA/ifcvf: Fix return value check for vdpa_alloc_device()
The vdpa_alloc_device() returns an error pointer upon failure, not NULL. To handle the failure correctly, this replaces NULL check with IS_ERR() check and propagate the error upwards. Fixes: 5a2414b ("virtio: Intel IFC VF driver for VDPA") Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Xie Yongji <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Jason Wang <[email protected]> Reviewed-by: Stefano Garzarella <[email protected]>
1 parent 9632e78 commit 1057afa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/vdpa/ifcvf/ifcvf_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,9 @@ static int ifcvf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
493493

494494
adapter = vdpa_alloc_device(struct ifcvf_adapter, vdpa,
495495
dev, &ifc_vdpa_ops, NULL);
496-
if (adapter == NULL) {
496+
if (IS_ERR(adapter)) {
497497
IFCVF_ERR(pdev, "Failed to allocate vDPA structure");
498-
return -ENOMEM;
498+
return PTR_ERR(adapter);
499499
}
500500

501501
pci_set_master(pdev);

0 commit comments

Comments
 (0)