aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/files/0332-drm-amdgpu-fix-error-handling-in-amdgpu_bo_list_set.patch
blob: e1805e4f08e87341133316130251d81a15ffc0a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
From a6279124b1e32280541b288b0b6bf34613378fea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20K=C3=B6nig?= <christian.koenig@amd.com>
Date: Mon, 22 Feb 2016 15:11:56 +0100
Subject: [PATCH 0332/1110] drm/amdgpu: fix error handling in
 amdgpu_bo_list_set
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Don't leak BOs in case of some error.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Kalyan Alle <kalyan.alle@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
index 53b1ebf..3406527 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
@@ -118,6 +118,7 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
                 usermm = amdgpu_ttm_tt_get_usermm(entry->robj->tbo.ttm);
                 if (usermm) {
                         if (usermm != current->mm) {
+                                amdgpu_bo_unref(&entry->robj);
                                 r = -EPERM;
                                 goto error_free;
                         }
@@ -151,6 +152,8 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
 	return 0;
 
 error_free:
+        while (i--)
+                amdgpu_bo_unref(&array[i].robj);
 	drm_free_large(array);
         return r;
 }
-- 
2.7.4