提交 b2d44e23 编写于 作者: E Egbert Eich 提交者: Dave Airlie

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: NEgbert Eich <eich@suse.de>
Signed-off-by: NTakashi Iwai <tiwai@suse.de>
Signed-off-by: NDave Airlie <airlied@redhat.com>
上级 f3b91060
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册