diff options
author | Egbert Eich <eich@suse.de> | 2017-07-18 17:47:38 +0300 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2017-08-02 05:12:31 +0300 |
commit | b2d44e23818a72ded7b8e9a08d46d532f0148465 (patch) | |
tree | 51bd8c67c80c0159031d4517702759f386fc86ac /drivers/gpu/drm/ast | |
parent | f3b91060b5e4ae89fb7132b9e8e1958b829ddc22 (diff) | |
download | linux-b2d44e23818a72ded7b8e9a08d46d532f0148465.tar.xz |
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>
Diffstat (limited to 'drivers/gpu/drm/ast')
-rw-r--r-- | drivers/gpu/drm/ast/ast_ttm.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c index 0b4c574defe7..696a15dc2f3f 100644 --- a/drivers/gpu/drm/ast/ast_ttm.c +++ b/drivers/gpu/drm/ast/ast_ttm.c @@ -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; @@ -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) |