[PATCH] drm/radeon: fix possible memory leak in radeon_bo_create

Alex Deucher alexdeucher at gmail.com
Tue Nov 21 04:36:57 UTC 2017


if ttm_bo_init fails, don't leak the bo object.

Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
---
 drivers/gpu/drm/radeon/radeon_object.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
index 093594976126..53c5bb6c25e4 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -262,6 +262,8 @@ int radeon_bo_create(struct radeon_device *rdev,
 			acc_size, sg, resv, &radeon_ttm_bo_destroy);
 	up_read(&rdev->pm.mclk_lock);
 	if (unlikely(r != 0)) {
+		drm_gem_object_release(&bo->gem_base);
+		kfree(bo);
 		return r;
 	}
 	*bo_ptr = bo;
-- 
2.13.6



More information about the amd-gfx mailing list