virtio/virtio_pci_legacy_dev: ensure the correct return value
authorPeng Hao <flyingpenghao@gmail.com>
Wed, 22 Dec 2021 11:20:14 +0000 (19:20 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 14 Jan 2022 23:50:53 +0000 (18:50 -0500)
When pci_iomap return NULL, the return value is zero.

Signed-off-by: Peng Hao <flyingpeng@tencent.com>
Link: https://lore.kernel.org/r/20211222112014.87394-1-flyingpeng@tencent.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
drivers/virtio/virtio_pci_legacy_dev.c

index 9b97680dd02b574bc0b009db01b51ec5b014c56d..677d1f68bc9bf25aca2e3fb6e8df57eacc42daef 100644 (file)
@@ -45,8 +45,10 @@ int vp_legacy_probe(struct virtio_pci_legacy_device *ldev)
                return rc;
 
        ldev->ioaddr = pci_iomap(pci_dev, 0, 0);
-       if (!ldev->ioaddr)
+       if (!ldev->ioaddr) {
+               rc = -EIO;
                goto err_iomap;
+       }
 
        ldev->isr = ldev->ioaddr + VIRTIO_PCI_ISR;