提交 5f646ffd 编写于 作者: X Xu Yandong 提交者: Michal Privoznik

qemuSharedDeviceEntryRemove: Free domain name before VIR_DELETE_ELEMENT

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: NXu Yandong <xuyandong2@huawei.com>
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 89d724b1
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册