mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-31 18:15:25 +00:00
qemu: fix memory leak and check mdevPath
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
45b639bdba
commit
d58c146a4f
@ -5229,11 +5229,13 @@ qemuBuildHostdevMediatedDevStr(const virDomainDef *def,
|
||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||
virDomainHostdevSubsysMediatedDevPtr mdevsrc = &dev->source.subsys.u.mdev;
|
||||
char *ret = NULL;
|
||||
char *mdevPath = NULL;
|
||||
|
||||
if (!(mdevPath = virMediatedDeviceGetSysfsPath(mdevsrc->uuidstr)))
|
||||
goto cleanup;
|
||||
|
||||
virBufferAddLit(&buf, "vfio-pci");
|
||||
virBufferAsprintf(&buf, ",id=%s,sysfsdev=%s",
|
||||
dev->info->alias,
|
||||
virMediatedDeviceGetSysfsPath(mdevsrc->uuidstr));
|
||||
virBufferAsprintf(&buf, ",id=%s,sysfsdev=%s", dev->info->alias, mdevPath);
|
||||
|
||||
if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0)
|
||||
goto cleanup;
|
||||
@ -5244,6 +5246,7 @@ qemuBuildHostdevMediatedDevStr(const virDomainDef *def,
|
||||
ret = virBufferContentAndReset(&buf);
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(mdevPath);
|
||||
virBufferFreeAndReset(&buf);
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user