acrn/dm: Remove the memory leak in gvt mediator

Otherwise it causes the memory leak.

V1->V2: Fix the leak of pi->arg as gvt structure also needs to be released.

Tracked-On: #2762
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: He, Min <min.he@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
This commit is contained in:
Zhao Yakui 2019-03-13 14:57:02 +08:00 committed by Eddie Dong
parent 065e16d32e
commit 31cb4721e1
1 changed files with 9 additions and 0 deletions

View File

@ -262,9 +262,18 @@ pci_gvt_deinit(struct vmctx *ctx, struct pci_vdev *pi, char *opts)
int ret;
struct pci_gvt *gvt = pi->arg;
if (gvt && gvt->host_config) {
/* Free the allocated host_config */
free(gvt->host_config);
gvt->host_config = NULL;
}
ret = gvt_destroy_instance(gvt);
if (ret)
WPRINTF(("GVT: %s: failed: errno=%d\n", __func__, ret));
free(gvt);
pi->arg = NULL;
}
struct pci_vdev_ops pci_ops_gvt = {