Commit 812a7df6556faae25deb42dbcc9e47829855556f

Authored by Arvind Yadav
Committed by Greg Kroah-Hartman
1 parent a417ea5b9d

vfio-pci: Handle error from pci_iomap

[ Upstream commit e19f32da5ded958238eac1bbe001192acef191a2 ]

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>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 4 additions and 0 deletions Side-by-side Diff

drivers/vfio/pci/vfio_pci.c
... ... @@ -1173,6 +1173,10 @@
1173 1173 return ret;
1174 1174  
1175 1175 vdev->barmap[index] = pci_iomap(pdev, index, 0);
  1176 + if (!vdev->barmap[index]) {
  1177 + pci_release_selected_regions(pdev, 1 << index);
  1178 + return -ENOMEM;
  1179 + }
1176 1180 }
1177 1181  
1178 1182 vma->vm_private_data = vdev;