lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Sun,  3 Apr 2022 09:23:52 +0200
From:   Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:     "Michael S. Tsirkin" <mst@...hat.com>,
        Jason Wang <jasowang@...hat.com>
Cc:     linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
        Christophe JAILLET <christophe.jaillet@...adoo.fr>,
        virtualization@...ts.linux-foundation.org
Subject: [PATCH] vp_vdpa: Fix an error handling path in vp_vdpa_probe()

If an error occurs after a successful vp_modern_probe() call, it should be
undone by a corresponding vp_modern_remove() call, as already do in the
remove function.

Fixes: 64b9f64f80a6 ("vdpa: introduce virtio pci driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
---
This patch is completely speculative.
Review with care.
---
 drivers/vdpa/virtio_pci/vp_vdpa.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/vdpa/virtio_pci/vp_vdpa.c b/drivers/vdpa/virtio_pci/vp_vdpa.c
index cce101e6a940..9b713fe0f2c7 100644
--- a/drivers/vdpa/virtio_pci/vp_vdpa.c
+++ b/drivers/vdpa/virtio_pci/vp_vdpa.c
@@ -491,7 +491,7 @@ static int vp_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	if (ret) {
 		dev_err(&pdev->dev,
 			"Failed for adding devres for freeing irq vectors\n");
-		goto err;
+		goto err_remove;
 	}
 
 	vp_vdpa->vring = devm_kcalloc(&pdev->dev, vp_vdpa->queues,
@@ -500,7 +500,7 @@ static int vp_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	if (!vp_vdpa->vring) {
 		ret = -ENOMEM;
 		dev_err(&pdev->dev, "Fail to allocate virtqueues\n");
-		goto err;
+		goto err_remove;
 	}
 
 	for (i = 0; i < vp_vdpa->queues; i++) {
@@ -511,7 +511,7 @@ static int vp_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		if (!vp_vdpa->vring[i].notify) {
 			ret = -EINVAL;
 			dev_warn(&pdev->dev, "Fail to map vq notify %d\n", i);
-			goto err;
+			goto err_remove;
 		}
 	}
 	vp_vdpa->config_irq = VIRTIO_MSI_NO_VECTOR;
@@ -519,11 +519,13 @@ static int vp_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	ret = vdpa_register_device(&vp_vdpa->vdpa, vp_vdpa->queues);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to register to vdpa bus\n");
-		goto err;
+		goto err_remove;
 	}
 
 	return 0;
 
+err_remove:
+	vp_modern_remove(&vp_vdpa->mdev);
 err:
 	put_device(&vp_vdpa->vdpa.dev);
 	return ret;
-- 
2.32.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ