]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuSharedDeviceEntryRemove: Free domain name before VIR_DELETE_ELEMENT
authorXu Yandong <xuyandong2@huawei.com>
Thu, 19 Sep 2019 08:02:07 +0000 (04:02 -0400)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 19 Sep 2019 14:32:56 +0000 (16:32 +0200)
The macro VIR_DELETE_ELEMENT assume that the items being deleted
have already been cleared, so we must explicitly free domain name
from the list of domains using the shared device to prevent a
memory leak.

Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_conf.c

index 1aeec30f8af645434e436d4e8ef0c15caeed875d..db390d358e1b7b1e2307205a1b89d31ffd256719 100644 (file)
@@ -1620,10 +1620,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;
 }