Skip to content

Commit a393c73

Browse files
thomashvmwairlied
authored andcommitted
drm/ttm: Fix buffer object metadata accounting regression v2
A regression was introduced in the 3.3 rc series, commit "drm/ttm: simplify memory accounting for ttm user v2", causing the metadata of buffer objects created using the ttm_bo_create() function to be accounted twice. That causes massive leaks with the vmwgfx driver running for example SpecViewperf Catia-03 test 2, eventually killing the app. Furthermore, the same commit introduces a regression where metadata accounting is leaked if a buffer object is initialized with an illegal size. This is also fixed with this commit. v2: Fixed an error path and removed an unused variable. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: Jerome Glisse <jglisse@redhat.com> Cc: stable@vger.kernel.org Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent fe45616 commit a393c73

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

‎drivers/gpu/drm/ttm/ttm_bo.c‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,7 @@ int ttm_bo_init(struct ttm_bo_device *bdev,
12041204
(*destroy)(bo);
12051205
else
12061206
kfree(bo);
1207+
ttm_mem_global_free(mem_glob, acc_size);
12071208
return -EINVAL;
12081209
}
12091210
bo->destroy = destroy;
@@ -1307,22 +1308,14 @@ int ttm_bo_create(struct ttm_bo_device *bdev,
13071308
struct ttm_buffer_object **p_bo)
13081309
{
13091310
struct ttm_buffer_object *bo;
1310-
struct ttm_mem_global *mem_glob = bdev->glob->mem_glob;
13111311
size_t acc_size;
13121312
int ret;
13131313

1314-
acc_size = ttm_bo_acc_size(bdev, size, sizeof(struct ttm_buffer_object));
1315-
ret = ttm_mem_global_alloc(mem_glob, acc_size, false, false);
1316-
if (unlikely(ret != 0))
1317-
return ret;
1318-
13191314
bo = kzalloc(sizeof(*bo), GFP_KERNEL);
1320-
1321-
if (unlikely(bo == NULL)) {
1322-
ttm_mem_global_free(mem_glob, acc_size);
1315+
if (unlikely(bo == NULL))
13231316
return -ENOMEM;
1324-
}
13251317

1318+
acc_size = ttm_bo_acc_size(bdev, size, sizeof(struct ttm_buffer_object));
13261319
ret = ttm_bo_init(bdev, bo, size, type, placement, page_alignment,
13271320
buffer_start, interruptible,
13281321
persistent_swap_storage, acc_size, NULL, NULL);

0 commit comments

Comments
 (0)