Skip to content

Commit 7552ed8

Browse files
airliedkraxel
authored andcommitted
virtio-gpu: don't free things on ttm_bo_init failure
ttm_bo_init will call the destroy callback which will do all this, this was causing a double free. Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent 6d41533 commit 7552ed8

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

‎drivers/gpu/drm/virtio/virtgpu_object.c‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,24 +82,19 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev,
8282
size = roundup(size, PAGE_SIZE);
8383
ret = drm_gem_object_init(vgdev->ddev, &bo->gem_base, size);
8484
if (ret != 0)
85-
goto err_gem_init;
85+
return ret;
8686
bo->dumb = false;
8787
virtio_gpu_init_ttm_placement(bo, pinned);
8888

8989
ret = ttm_bo_init(&vgdev->mman.bdev, &bo->tbo, size, type,
9090
&bo->placement, 0, !kernel, NULL, acc_size,
9191
NULL, NULL, &virtio_gpu_ttm_bo_destroy);
92+
/* ttm_bo_init failure will call the destroy */
9293
if (ret != 0)
93-
goto err_ttm_init;
94+
return ret;
9495

9596
*bo_ptr = bo;
9697
return 0;
97-
98-
err_ttm_init:
99-
drm_gem_object_release(&bo->gem_base);
100-
err_gem_init:
101-
kfree(bo);
102-
return ret;
10398
}
10499

105100
int virtio_gpu_object_kmap(struct virtio_gpu_object *bo, void **ptr)

0 commit comments

Comments
 (0)