[PATCH] virtio: vdpa: fix kernel warning in snet_vdpa_remove_vf

Alvaro Karsz
Wed, 04 Jan 2023 12:13:22 -0000

Call pci_free_irq_vectors after calling vdpa_unregister_device.
Otherwise, we get the following kernel warning:

	remove_proc_entry: removing non-empty directory 'irq/..',
	leaking at least '..'

This happens only if SNET_CFG_FLAG_IRQ_PF flag is not set.

This patch should be applied on top of:
virtio: vdpa: new SolidNET DPU driver,
by Alvaro Karsz alvaro.karsz at solid-run.com

Signed-off-by: Alvaro Karsz <alvaro.karsz at solid-run.com>
---
 drivers/vdpa/solidrun/snet_main.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/vdpa/solidrun/snet_main.c
b/drivers/vdpa/solidrun/snet_main.c
index 9ceacf96de0..0c13ccde452 100644
--- a/drivers/vdpa/solidrun/snet_main.c
+++ b/drivers/vdpa/solidrun/snet_main.c
@@ -1073,12 +1073,11 @@ static void snet_vdpa_remove_vf(struct pci_dev *pdev)
 	struct snet *snet = pci_get_drvdata(pdev);
 	struct psnet *psnet = snet->psnet;

+	vdpa_unregister_device(&snet->vdpa);
+	snet_free_vqs(snet);
 	/* If IRQs are allocated from the VF, we should free the IRQs */
 	if (!PSNET_FLAG_ON(psnet, SNET_CFG_FLAG_IRQ_PF))
 		pci_free_irq_vectors(pdev);
-
-	vdpa_unregister_device(&snet->vdpa);
-	snet_free_vqs(snet);
 }

 static void snet_vdpa_remove(struct pci_dev *pdev)
--
2.32.0