mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-22 17:27:53 +00:00
ACRN:DM: Fix the memory_leak of vga_context in virtio_gpu_deinit
Otherwise the memory related with vga_context is leaked. v1->v2: Use the pthread_join instead of usleep to wait for the termination of vga_thread. Tracked-On: #7296 Acked-by: Wang Yu1 <yu1.wang@intel.com> Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
This commit is contained in:
@@ -1644,6 +1644,20 @@ virtio_gpu_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
||||
gpu = (struct virtio_gpu *)dev->arg;
|
||||
gpu->vga.enable = false;
|
||||
|
||||
pthread_mutex_lock(&gpu->vga_thread_mtx);
|
||||
if (atomic_load(&gpu->vga_thread_status) != VGA_THREAD_EOL) {
|
||||
pthread_mutex_unlock(&gpu->vga_thread_mtx);
|
||||
pthread_join(gpu->vga.tid, NULL);
|
||||
} else
|
||||
pthread_mutex_unlock(&gpu->vga_thread_mtx);
|
||||
|
||||
if (gpu->vga.dev)
|
||||
vga_deinit(&gpu->vga);
|
||||
if (gpu->vga.gc) {
|
||||
gc_deinit(gpu->vga.gc);
|
||||
gpu->vga.gc = NULL;
|
||||
}
|
||||
|
||||
pthread_mutex_destroy(&gpu->vga_thread_mtx);
|
||||
while (LIST_FIRST(&gpu->r2d_list)) {
|
||||
r2d = LIST_FIRST(&gpu->r2d_list);
|
||||
|
Reference in New Issue
Block a user