platform-bus: fix refcount leak
memory_region_find() returns an MR which it is the caller's responsibility to unref, but platform_bus_map_mmio() was forgetting to do so, thus leaking the MR. Signed-off-by: Gao Shiyuan <gaoshiyuan@baidu.com> Message-id: 20240829131005.9196-1-gaoshiyuan@baidu.com Reviewed-by: Peter Maydell <peter.maydell@linaro.org> [PMM: tweaked commit message] Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
17e93dd5fa
commit
99ec7b440a
@ -145,9 +145,12 @@ static void platform_bus_map_mmio(PlatformBusDevice *pbus, SysBusDevice *sbdev,
|
||||
* the target device's memory region
|
||||
*/
|
||||
for (off = 0; off < pbus->mmio_size; off += alignment) {
|
||||
if (!memory_region_find(&pbus->mmio, off, size).mr) {
|
||||
MemoryRegion *mr = memory_region_find(&pbus->mmio, off, size).mr;
|
||||
if (!mr) {
|
||||
found_region = true;
|
||||
break;
|
||||
} else {
|
||||
memory_region_unref(mr);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user