diff options
author | Michel Dänzer <michel.daenzer@amd.com> | 2018-09-12 12:07:10 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-09-14 10:37:17 -0400 |
commit | 6a15f3ff19a8dd394e3a21480512c2cb98e26b3c (patch) | |
tree | dec9fec3936245a92700ac5792af8c3d062070c6 /drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c | |
parent | 520cbe0f4a7f170ec0d1167a827bcbec74aef4f4 (diff) |
drm/amdgpu: Initialize fences array entries in amdgpu_sa_bo_next_hole
The entries were only initialized once in amdgpu_sa_bo_new. If a fence
wasn't signalled yet in the first amdgpu_sa_bo_next_hole call, but then
got signalled before a later amdgpu_sa_bo_next_hole call, it could
destroy the fence but leave its pointer in the array, resulting in
use-after-free in amdgpu_sa_bo_new.
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c index fb1667b35daa..12f2bf97611f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c | |||
@@ -226,6 +226,8 @@ static bool amdgpu_sa_bo_next_hole(struct amdgpu_sa_manager *sa_manager, | |||
226 | for (i = 0; i < AMDGPU_SA_NUM_FENCE_LISTS; ++i) { | 226 | for (i = 0; i < AMDGPU_SA_NUM_FENCE_LISTS; ++i) { |
227 | struct amdgpu_sa_bo *sa_bo; | 227 | struct amdgpu_sa_bo *sa_bo; |
228 | 228 | ||
229 | fences[i] = NULL; | ||
230 | |||
229 | if (list_empty(&sa_manager->flist[i])) | 231 | if (list_empty(&sa_manager->flist[i])) |
230 | continue; | 232 | continue; |
231 | 233 | ||
@@ -296,10 +298,8 @@ int amdgpu_sa_bo_new(struct amdgpu_sa_manager *sa_manager, | |||
296 | 298 | ||
297 | spin_lock(&sa_manager->wq.lock); | 299 | spin_lock(&sa_manager->wq.lock); |
298 | do { | 300 | do { |
299 | for (i = 0; i < AMDGPU_SA_NUM_FENCE_LISTS; ++i) { | 301 | for (i = 0; i < AMDGPU_SA_NUM_FENCE_LISTS; ++i) |
300 | fences[i] = NULL; | ||
301 | tries[i] = 0; | 302 | tries[i] = 0; |
302 | } | ||
303 | 303 | ||
304 | do { | 304 | do { |
305 | amdgpu_sa_bo_try_free(sa_manager); | 305 | amdgpu_sa_bo_try_free(sa_manager); |