Commit b66574a3 authored by Alex Williamson's avatar Alex Williamson

vfio/pci: Cleanup .probe() exit paths

The cleanup is getting a tad long.
Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
Reviewed-by: default avatarKevin Tian <kevin.tian@intel.com>
Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent 959e1b75
...@@ -1598,8 +1598,8 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1598,8 +1598,8 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
vdev = kzalloc(sizeof(*vdev), GFP_KERNEL); vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
if (!vdev) { if (!vdev) {
vfio_iommu_group_put(group, &pdev->dev); ret = -ENOMEM;
return -ENOMEM; goto out_group_put;
} }
vdev->pdev = pdev; vdev->pdev = pdev;
...@@ -1610,43 +1610,27 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1610,43 +1610,27 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
INIT_LIST_HEAD(&vdev->ioeventfds_list); INIT_LIST_HEAD(&vdev->ioeventfds_list);
ret = vfio_add_group_dev(&pdev->dev, &vfio_pci_ops, vdev); ret = vfio_add_group_dev(&pdev->dev, &vfio_pci_ops, vdev);
if (ret) { if (ret)
vfio_iommu_group_put(group, &pdev->dev); goto out_free;
kfree(vdev);
return ret;
}
ret = vfio_pci_reflck_attach(vdev); ret = vfio_pci_reflck_attach(vdev);
if (ret) { if (ret)
vfio_del_group_dev(&pdev->dev); goto out_del_group_dev;
vfio_iommu_group_put(group, &pdev->dev);
kfree(vdev);
return ret;
}
if (pdev->is_physfn) { if (pdev->is_physfn) {
vdev->vf_token = kzalloc(sizeof(*vdev->vf_token), GFP_KERNEL); vdev->vf_token = kzalloc(sizeof(*vdev->vf_token), GFP_KERNEL);
if (!vdev->vf_token) { if (!vdev->vf_token) {
vfio_pci_reflck_put(vdev->reflck); ret = -ENOMEM;
vfio_del_group_dev(&pdev->dev); goto out_reflck;
vfio_iommu_group_put(group, &pdev->dev);
kfree(vdev);
return -ENOMEM;
}
vdev->nb.notifier_call = vfio_pci_bus_notifier;
ret = bus_register_notifier(&pci_bus_type, &vdev->nb);
if (ret) {
kfree(vdev->vf_token);
vfio_pci_reflck_put(vdev->reflck);
vfio_del_group_dev(&pdev->dev);
vfio_iommu_group_put(group, &pdev->dev);
kfree(vdev);
return ret;
} }
mutex_init(&vdev->vf_token->lock); mutex_init(&vdev->vf_token->lock);
uuid_gen(&vdev->vf_token->uuid); uuid_gen(&vdev->vf_token->uuid);
vdev->nb.notifier_call = vfio_pci_bus_notifier;
ret = bus_register_notifier(&pci_bus_type, &vdev->nb);
if (ret)
goto out_vf_token;
} }
if (vfio_pci_is_vga(pdev)) { if (vfio_pci_is_vga(pdev)) {
...@@ -1672,6 +1656,18 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1672,6 +1656,18 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
} }
return ret; return ret;
out_vf_token:
kfree(vdev->vf_token);
out_reflck:
vfio_pci_reflck_put(vdev->reflck);
out_del_group_dev:
vfio_del_group_dev(&pdev->dev);
out_free:
kfree(vdev);
out_group_put:
vfio_iommu_group_put(group, &pdev->dev);
return ret;
} }
static void vfio_pci_remove(struct pci_dev *pdev) static void vfio_pci_remove(struct pci_dev *pdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment