vdpa: Fix an error handling path in eni_vdpa_probe()
[platform/kernel/linux-starfive.git] / drivers / vdpa / alibaba / eni_vdpa.c
index 5a09a09..cce3d18 100644 (file)
@@ -497,7 +497,7 @@ static int eni_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        if (!eni_vdpa->vring) {
                ret = -ENOMEM;
                ENI_ERR(pdev, "failed to allocate virtqueues\n");
-               goto err;
+               goto err_remove_vp_legacy;
        }
 
        for (i = 0; i < eni_vdpa->queues; i++) {
@@ -509,11 +509,13 @@ static int eni_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        ret = vdpa_register_device(&eni_vdpa->vdpa, eni_vdpa->queues);
        if (ret) {
                ENI_ERR(pdev, "failed to register to vdpa bus\n");
-               goto err;
+               goto err_remove_vp_legacy;
        }
 
        return 0;
 
+err_remove_vp_legacy:
+       vp_legacy_remove(&eni_vdpa->ldev);
 err:
        put_device(&eni_vdpa->vdpa.dev);
        return ret;