From: Arvind Yadav Date: Tue, 3 Jan 2017 11:56:46 +0000 (+0530) Subject: vfio-pci: Handle error from pci_iomap X-Git-Tag: v4.14-rc1~1737^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e19f32da5ded958238eac1bbe001192acef191a2;p=platform%2Fkernel%2Flinux-rpi.git vfio-pci: Handle error from pci_iomap Here, pci_iomap can fail, handle this case release selected pci regions and return -ENOMEM. Signed-off-by: Arvind Yadav Signed-off-by: Alex Williamson --- diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index dcd7c2a..324c52e 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -1142,6 +1142,10 @@ static int vfio_pci_mmap(void *device_data, struct vm_area_struct *vma) return ret; vdev->barmap[index] = pci_iomap(pdev, index, 0); + if (!vdev->barmap[index]) { + pci_release_selected_regions(pdev, 1 << index); + return -ENOMEM; + } } vma->vm_private_data = vdev;