Skip to content

Commit 31cb472

Browse files
yakuizhaoEddie Dong
authored andcommitted
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>
1 parent 065e16d commit 31cb472

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

devicemodel/hw/pci/gvt.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,18 @@ pci_gvt_deinit(struct vmctx *ctx, struct pci_vdev *pi, char *opts)
262262
int ret;
263263
struct pci_gvt *gvt = pi->arg;
264264

265+
if (gvt && gvt->host_config) {
266+
/* Free the allocated host_config */
267+
free(gvt->host_config);
268+
gvt->host_config = NULL;
269+
}
270+
265271
ret = gvt_destroy_instance(gvt);
266272
if (ret)
267273
WPRINTF(("GVT: %s: failed: errno=%d\n", __func__, ret));
274+
275+
free(gvt);
276+
pi->arg = NULL;
268277
}
269278

270279
struct pci_vdev_ops pci_ops_gvt = {

0 commit comments

Comments
 (0)