[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/1] platform-bus: fix refcount leak
From: |
Gao Shiyuan |
Subject: |
[PATCH 1/1] platform-bus: fix refcount leak |
Date: |
Thu, 29 Aug 2024 21:10:05 +0800 |
Temporary object causes reference count leakage.
Signed-off-by: Gao Shiyuan <gaoshiyuan@baidu.com>
---
hw/core/platform-bus.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/hw/core/platform-bus.c b/hw/core/platform-bus.c
index b8487b26b6..dc58bf505a 100644
--- a/hw/core/platform-bus.c
+++ b/hw/core/platform-bus.c
@@ -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);
}
}
--
2.39.3 (Apple Git-146)
- [PATCH 1/1] platform-bus: fix refcount leak,
Gao Shiyuan <=