[PATCH 00/22] Fix memory region leaks and use-after-finalization

Akihiko Odaki posted 22 patches 10 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250906-use-v1-0-c51caafd1eb7@rsg.ci.i.u-tokyo.ac.jp
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Helge Deller <deller@gmx.de>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Eduardo Habkost <eduardo@habkost.net>, Gerd Hoffmann <kraxel@redhat.com>, John Snow <jsnow@redhat.com>, Keith Busch <kbusch@kernel.org>, Klaus Jensen <its@irrelevant.dk>, Jesper Devantier <foss@defmacro.it>, "Hervé Poussineau" <hpoussin@reactos.org>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Nicholas Piggin <npiggin@gmail.com>, Harsh Prateek Bora <harshpb@linux.ibm.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Artyom Tarasenko <atar4qemu@gmail.com>, John Levon <john.levon@nutanix.com>, Thanos Makatos <thanos.makatos@nutanix.com>, "Cédric Le Goater" <clg@redhat.com>, Alex Williamson <alex.williamson@redhat.com>, Peter Xu <peterx@redhat.com>, David Hildenbrand <david@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Aurelien Jarno <aurelien@aurel32.net>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Aleksandar Rikalo <arikalo@gmail.com>, Max Filippov <jcmvbkbc@gmail.com>
MAINTAINERS                |  1 +
docs/devel/memory.rst      | 19 +++------
include/hw/pci/pci.h       |  1 +
include/hw/qdev-core.h     |  1 +
hw/char/diva-gsp.c         |  1 -
hw/char/serial-pci-multi.c |  1 -
hw/core/qdev.c             | 14 +++++++
hw/display/vga-pci.c       |  8 ----
hw/ide/cmd646.c            | 12 ------
hw/ide/piix.c              | 13 -------
hw/ide/via.c               | 12 ------
hw/misc/auxbus.c           |  2 +-
hw/nvme/ctrl.c             |  2 -
hw/pci-host/raven.c        | 27 ++++++-------
hw/pci/pci.c               | 22 +----------
hw/pci/pci_bridge.c        | 96 +++++++++++++++++++++++++---------------------
hw/ppc/spapr_pci.c         | 22 -----------
hw/sparc/sun4m_iommu.c     |  9 ++++-
hw/sparc64/sun4u_iommu.c   |  9 ++++-
hw/usb/hcd-ehci.c          |  4 --
hw/usb/hcd-xhci.c          | 10 -----
hw/vfio-user/pci.c         |  6 ---
hw/vfio/pci.c              |  4 --
stubs/memory.c             |  9 +++++
target/mips/cpu.c          |  9 ++++-
target/xtensa/cpu.c        |  8 ++--
stubs/meson.build          |  1 +
27 files changed, 129 insertions(+), 194 deletions(-)
[PATCH 00/22] Fix memory region leaks and use-after-finalization
Posted by Akihiko Odaki 10 hours ago
When developing the next version of "[PATCH 00/16] memory: Stop
piggybacking on memory region owners*", I faced multiple memory region
leaks and use-after-finalization. This series extracts their fixes so
that the number of Cc: won't explode.

Patch "qdev: Automatically delete memory subregions" and the succeeding
patches are for refactoring, but patch "vfio-user: Do not delete the
subregion" does fix use-after-finalization.

* https://lore.kernel.org/qemu-devel/20250901-mr-v1-0-dd7cb6b1480b@rsg.ci.i.u-tokyo.ac.jp/

Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
---
Akihiko Odaki (22):
      docs/devel: Do not unparent in instance_finalize()
      vfio/pci: Do not unparent in instance_finalize()
      hw/pci-bridge: Do not assume immediate MemoryRegion finalization
      target/mips: Fix AddressSpace exposure timing
      target/xtensa: Fix AddressSpace exposure timing
      auxbus: Fix AddressSpace exposure timing
      hw/pci-host/raven: Fix AddressSpace exposure timing
      sun4m: Fix AddressSpace exposure timing
      sun4u: Fix AddressSpace exposure timing
      qdev: Automatically delete memory subregions
      vfio-user: Do not delete the subregion
      hw/char/diva-gsp: Do not delete the subregion
      hw/char/serial-pci-multi: Do not delete the subregion
      secondary-vga: Do not delete the subregions
      cmd646: Do not delete the subregions
      hw/ide/piix: Do not delete the subregions
      hw/ide/via: Do not delete the subregions
      hw/nvme: Do not delete the subregion
      pci: Do not delete the subregions
      hw/ppc/spapr_pci: Do not delete the subregions
      hw/usb/hcd-ehci: Do not delete the subregions
      hw/usb/hcd-xhci: Do not delete the subregions

 MAINTAINERS                |  1 +
 docs/devel/memory.rst      | 19 +++------
 include/hw/pci/pci.h       |  1 +
 include/hw/qdev-core.h     |  1 +
 hw/char/diva-gsp.c         |  1 -
 hw/char/serial-pci-multi.c |  1 -
 hw/core/qdev.c             | 14 +++++++
 hw/display/vga-pci.c       |  8 ----
 hw/ide/cmd646.c            | 12 ------
 hw/ide/piix.c              | 13 -------
 hw/ide/via.c               | 12 ------
 hw/misc/auxbus.c           |  2 +-
 hw/nvme/ctrl.c             |  2 -
 hw/pci-host/raven.c        | 27 ++++++-------
 hw/pci/pci.c               | 22 +----------
 hw/pci/pci_bridge.c        | 96 +++++++++++++++++++++++++---------------------
 hw/ppc/spapr_pci.c         | 22 -----------
 hw/sparc/sun4m_iommu.c     |  9 ++++-
 hw/sparc64/sun4u_iommu.c   |  9 ++++-
 hw/usb/hcd-ehci.c          |  4 --
 hw/usb/hcd-xhci.c          | 10 -----
 hw/vfio-user/pci.c         |  6 ---
 hw/vfio/pci.c              |  4 --
 stubs/memory.c             |  9 +++++
 target/mips/cpu.c          |  9 ++++-
 target/xtensa/cpu.c        |  8 ++--
 stubs/meson.build          |  1 +
 27 files changed, 129 insertions(+), 194 deletions(-)
---
base-commit: e101d33792530093fa0b0a6e5f43e4d8cfe4581e
change-id: 20250906-use-37ecc903a9e0

Best regards,
-- 
Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>