Skip to content

Commit 9632e78

Browse files
YongjiXiemstsirkin
authored andcommitted
vp_vdpa: 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: 64b9f64 ("vdpa: introduce virtio pci driver") 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 2b847f2 commit 9632e78

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/vdpa/virtio_pci/vp_vdpa.c

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

437437
vp_vdpa = vdpa_alloc_device(struct vp_vdpa, vdpa,
438438
dev, &vp_vdpa_ops, NULL);
439-
if (vp_vdpa == NULL) {
439+
if (IS_ERR(vp_vdpa)) {
440440
dev_err(dev, "vp_vdpa: Failed to allocate vDPA structure\n");
441-
return -ENOMEM;
441+
return PTR_ERR(vp_vdpa);
442442
}
443443

444444
mdev = &vp_vdpa->mdev;

0 commit comments

Comments
 (0)