[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
QEMU device refcounting when device creates a container MR
From: |
Peter Maydell |
Subject: |
QEMU device refcounting when device creates a container MR |
Date: |
Wed, 9 Mar 2022 10:33:15 +0000 |
Hi; does anybody know how device reference counting is supposed
to work when the device creates a "container" MemoryRegion which
it then puts some of its own subregions in to?
As far as I can see when you do memory_region_add_subregion it
increases the refcount on the owner of the subregion. So if a
device creates a container MR in its own init or realize method
and adds sub-MRs that it owns to that container, this increases
the refcount on the device permanently, and so the device won't
ever be deinited.
As a specific example, the usb-chipidea device does this in its
init method, so if you run the arm device-introspect-test under
leak-sanitizer it complains about a memory leak that happens
when the device is put through the "init-introspect-deref" cycle.
-- PMM