Skip to content

Commit

Permalink
drm/ast: Fix memleak in error path in ast_bo_create()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Egbert Eich authored and Dave Airlie committed Aug 2, 2017
1 parent f3b9106 commit b2d44e2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions drivers/gpu/drm/ast/ast_ttm.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,8 @@ int ast_bo_create(struct drm_device *dev, int size, int align,
return -ENOMEM;

ret = drm_gem_object_init(dev, &astbo->gem, size);
if (ret) {
kfree(astbo);
return ret;
}
if (ret)
goto error;

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

Expand All @@ -340,10 +338,13 @@ int ast_bo_create(struct drm_device *dev, int size, int align,
align >> PAGE_SHIFT, false, NULL, acc_size,
NULL, NULL, ast_bo_ttm_destroy);
if (ret)
return ret;
goto error;

*pastbo = astbo;
return 0;
error:
kfree(astbo);
return ret;
}

static inline u64 ast_bo_gpu_offset(struct ast_bo *bo)
Expand Down

0 comments on commit b2d44e2

Please sign in to comment.