37 lines
1.1 KiB
Diff
37 lines
1.1 KiB
Diff
From ba3884fbb6321923d6b3f88dce82ba01974f8a4d Mon Sep 17 00:00:00 2001
|
|
From: Xu Yandong <xuyandong2@huawei.com>
|
|
Date: Thu, 25 Jul 2019 12:18:23 +0800
|
|
Subject: [PATCH] qemu_conf: clear domain before VIR_DELETE_ELEMENT
|
|
|
|
The macro VIR_DELETE_ELEMENT assume that the items being deleted have
|
|
already been cleared, so we must explicitly delete domain memory to
|
|
prevent a memory leak.
|
|
|
|
Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
|
|
---
|
|
src/qemu/qemu_conf.c | 6 ++++--
|
|
1 file changed, 4 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
|
|
index 8312f99..29bd07e 100644
|
|
--- a/src/qemu/qemu_conf.c
|
|
+++ b/src/qemu/qemu_conf.c
|
|
@@ -1672,10 +1672,12 @@ qemuSharedDeviceEntryRemove(virQEMUDriverPtr driver,
|
|
if (!qemuSharedDeviceEntryDomainExists(entry, name, &idx))
|
|
return 0;
|
|
|
|
- if (entry->ref != 1)
|
|
+ if (entry->ref != 1) {
|
|
+ VIR_FREE(entry->domains[idx]);
|
|
VIR_DELETE_ELEMENT(entry->domains, idx, entry->ref);
|
|
- else
|
|
+ } else {
|
|
ignore_value(virHashRemoveEntry(driver->sharedDevices, key));
|
|
+ }
|
|
|
|
return 0;
|
|
}
|
|
--
|
|
2.19.1
|
|
|