[Concept,06/33] virtio: Free mmio base when removing sandbox virtio emul

Message ID 20260416023021.626949-7-sjg@u-boot.org
State New
Headers
Series Fix memory leaks and test pollution in sandbox tests |

Commit Message

Simon Glass April 16, 2026, 2:29 a.m. UTC
  From: Simon Glass <sjg@chromium.org>

sandbox_emul_of_to_plat() used memalign() for its emulated MMIO region,
but sandbox_emul_remove() only unregisters the MMIO callback; the buffer
itself (several KB per device) is not freed.

Free it on removal.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/virtio/sandbox_emul.c | 3 +++
 1 file changed, 3 insertions(+)
  

Patch

diff --git a/drivers/virtio/sandbox_emul.c b/drivers/virtio/sandbox_emul.c
index 2c75fd546d1..cde666ce99d 100644
--- a/drivers/virtio/sandbox_emul.c
+++ b/drivers/virtio/sandbox_emul.c
@@ -283,7 +283,10 @@  static int sandbox_emul_of_to_plat(struct udevice *dev)
 
 static int sandbox_emul_remove(struct udevice *dev)
 {
+	struct sandbox_emul_priv *priv = dev_get_priv(dev);
+
 	sandbox_mmio_remove(dev);
+	free(priv->mmio.base);
 
 	return 0;
 }