Skip to content

Commit b2d44e2

Browse files
e4tairlied
authored andcommitted
drm/ast: Fix memleak in error path in ast_bo_create()
The allocated struct ast_bo was not freed in all error paths. This patch consolidates error handling and fixes this. Signed-off-by: Egbert Eich <eich@suse.de> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent f3b9106 commit b2d44e2

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

‎drivers/gpu/drm/ast/ast_ttm.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,8 @@ int ast_bo_create(struct drm_device *dev, int size, int align,
323323
return -ENOMEM;
324324

325325
ret = drm_gem_object_init(dev, &astbo->gem, size);
326-
if (ret) {
327-
kfree(astbo);
328-
return ret;
329-
}
326+
if (ret)
327+
goto error;
330328

331329
astbo->bo.bdev = &ast->ttm.bdev;
332330

@@ -340,10 +338,13 @@ int ast_bo_create(struct drm_device *dev, int size, int align,
340338
align >> PAGE_SHIFT, false, NULL, acc_size,
341339
NULL, NULL, ast_bo_ttm_destroy);
342340
if (ret)
343-
return ret;
341+
goto error;
344342

345343
*pastbo = astbo;
346344
return 0;
345+
error:
346+
kfree(astbo);
347+
return ret;
347348
}
348349

349350
static inline u64 ast_bo_gpu_offset(struct ast_bo *bo)

0 commit comments

Comments
 (0)