From: Arvind Yadav Date: Tue, 3 Jan 2017 11:56:46 +0000 (+0530) Subject: vfio-pci: Handle error from pci_iomap X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e19f32da5ded958238eac1bbe001192acef191a2;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.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 dcd7c2a99618..324c52e3a1a4 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;