linux-um archives
 help / color / mirror / Atom feed
From: Benjamin Berg <benjamin@sipsolutions.net>
To: linux-um@lists.infradead.org
Cc: Benjamin Berg <benjamin.berg@intel.com>
Subject: [PATCH] um: virtio-pci: free the IRQ message buffers
Date: Tue,  5 May 2026 14:43:18 +0200	[thread overview]
Message-ID: <20260505124317.2330700-2-benjamin@sipsolutions.net> (raw)

From: Benjamin Berg <benjamin.berg@intel.com>

These buffers are allocated when initializing the virtual queues, but
were not freed again. Wrap all of the del_vqs calls to detach and free
the unused buffers before deleting the IRQ VQ.

Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
---
 arch/um/drivers/virtio_pcidev.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/arch/um/drivers/virtio_pcidev.c b/arch/um/drivers/virtio_pcidev.c
index 2bf5a645db45..53cffd373890 100644
--- a/arch/um/drivers/virtio_pcidev.c
+++ b/arch/um/drivers/virtio_pcidev.c
@@ -490,13 +490,24 @@ static int virtio_pcidev_init_vqs(struct virtio_pcidev_device *dev)
 	return 0;
 }
 
+static void virtio_pcidev_del_vqs(struct virtio_device *vdev,
+				  struct virtio_pcidev_device *dev)
+{
+	void *msg;
+
+	while ((msg = virtqueue_detach_unused_buf(dev->irq_vq)))
+		kfree(msg);
+
+	vdev->config->del_vqs(vdev);
+}
+
 static void __virtio_pcidev_virtio_platform_remove(struct virtio_device *vdev,
 						   struct virtio_pcidev_device *dev)
 {
 	um_pci_platform_device_unregister(&dev->pdev);
 
 	virtio_reset_device(vdev);
-	vdev->config->del_vqs(vdev);
+	virtio_pcidev_del_vqs(vdev, dev);
 
 	kfree(dev);
 }
@@ -526,7 +537,7 @@ static int virtio_pcidev_virtio_platform_probe(struct virtio_device *vdev,
 	um_pci_platform_device_unregister(&dev->pdev);
 err_reset:
 	virtio_reset_device(vdev);
-	vdev->config->del_vqs(vdev);
+	virtio_pcidev_del_vqs(vdev, dev);
 err_free:
 	kfree(dev);
 	return err;
@@ -569,7 +580,7 @@ static int virtio_pcidev_virtio_probe(struct virtio_device *vdev)
 
 err_reset:
 	virtio_reset_device(vdev);
-	vdev->config->del_vqs(vdev);
+	virtio_pcidev_del_vqs(vdev, dev);
 err_free:
 	kfree(dev);
 	return err;
@@ -591,9 +602,9 @@ static void virtio_pcidev_virtio_remove(struct virtio_device *vdev)
 
 	/* Stop all virtqueues */
 	virtio_reset_device(vdev);
+	virtio_pcidev_del_vqs(vdev, dev);
 	dev->cmd_vq = NULL;
 	dev->irq_vq = NULL;
-	vdev->config->del_vqs(vdev);
 
 	kfree(dev);
 }
-- 
2.54.0



                 reply	other threads:[~2026-05-05 12:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260505124317.2330700-2-benjamin@sipsolutions.net \
    --to=benjamin@sipsolutions.net \
    --cc=benjamin.berg@intel.com \
    --cc=linux-um@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox