Skip to content

Commit 1253685

Browse files
Guchun Chenalexdeucher
authored andcommitted
drm/amdgpu: drop redundant sched job cleanup when cs is aborted
Once command submission failed due to userptr invalidation in amdgpu_cs_submit, legacy code will perform cleanup of scheduler job. However, it's not needed at all, as former commit has integrated job cleanup stuff into amdgpu_job_free. Otherwise, because of double free, a NULL pointer dereference will occur in such scenario. Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/2457 Fixes: f7d66fb ("drm/amdgpu: cleanup scheduler job initialization v2") Signed-off-by: Guchun Chen <guchun.chen@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org
1 parent 682439f commit 1253685

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
12761276
r = drm_sched_job_add_dependency(&leader->base, fence);
12771277
if (r) {
12781278
dma_fence_put(fence);
1279-
goto error_cleanup;
1279+
return r;
12801280
}
12811281
}
12821282

@@ -1303,7 +1303,8 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
13031303
}
13041304
if (r) {
13051305
r = -EAGAIN;
1306-
goto error_unlock;
1306+
mutex_unlock(&p->adev->notifier_lock);
1307+
return r;
13071308
}
13081309

13091310
p->fence = dma_fence_get(&leader->base.s_fence->finished);
@@ -1350,14 +1351,6 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
13501351
mutex_unlock(&p->adev->notifier_lock);
13511352
mutex_unlock(&p->bo_list->bo_list_mutex);
13521353
return 0;
1353-
1354-
error_unlock:
1355-
mutex_unlock(&p->adev->notifier_lock);
1356-
1357-
error_cleanup:
1358-
for (i = 0; i < p->gang_size; ++i)
1359-
drm_sched_job_cleanup(&p->jobs[i]->base);
1360-
return r;
13611354
}
13621355

13631356
/* Cleanup the parser structure */

0 commit comments

Comments
 (0)