diff options
author | Arvind Yadav <arvind.yadav.cs@gmail.com> | 2017-01-03 06:56:46 -0500 |
---|---|---|
committer | Alex Williamson <alex.williamson@redhat.com> | 2017-01-04 10:34:39 -0500 |
commit | e19f32da5ded958238eac1bbe001192acef191a2 (patch) | |
tree | b80aac9fe6e190097ea965a1bdbd1855c88f8367 | |
parent | d293dbaa540b5800817cc10832d764b17cc211b5 (diff) |
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 <arvind.yadav.cs@gmail.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
-rw-r--r-- | drivers/vfio/pci/vfio_pci.c | 4 |
1 files changed, 4 insertions, 0 deletions
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) | |||
1142 | return ret; | 1142 | return ret; |
1143 | 1143 | ||
1144 | vdev->barmap[index] = pci_iomap(pdev, index, 0); | 1144 | vdev->barmap[index] = pci_iomap(pdev, index, 0); |
1145 | if (!vdev->barmap[index]) { | ||
1146 | pci_release_selected_regions(pdev, 1 << index); | ||
1147 | return -ENOMEM; | ||
1148 | } | ||
1145 | } | 1149 | } |
1146 | 1150 | ||
1147 | vma->vm_private_data = vdev; | 1151 | vma->vm_private_data = vdev; |