Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b2d44e23 authored by Egbert Eich's avatar Egbert Eich Committed by Dave Airlie
Browse files

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: default avatarEgbert Eich <eich@suse.de>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent f3b91060
Loading
Loading
Loading
Loading
+6 −5
Original line number Original line Diff line number Diff line
@@ -323,10 +323,8 @@ int ast_bo_create(struct drm_device *dev, int size, int align,
		return -ENOMEM;
		return -ENOMEM;


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


	astbo->bo.bdev = &ast->ttm.bdev;
	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,
			  align >> PAGE_SHIFT, false, NULL, acc_size,
			  NULL, NULL, ast_bo_ttm_destroy);
			  NULL, NULL, ast_bo_ttm_destroy);
	if (ret)
	if (ret)
		return ret;
		goto error;


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


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