Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/amdgpu: avoid double drm_exec_fini() in userq validate

When new_addition is true, amdgpu_userq_vm_validate() calls
drm_exec_fini(&exec) before iterating over the collected HMM ranges and
calling amdgpu_ttm_tt_get_user_pages().

If amdgpu_ttm_tt_get_user_pages() fails in that path, the code jumps to
unlock_all and calls drm_exec_fini(&exec) a second time on the same
exec object. drm_exec_fini() is not idempotent: it frees exec->objects
and may also drop exec->contended and finalize the ww acquire context.

Route that error path directly to the range cleanup once exec has
already been finalized.

Fixes: 42f148788469 ("drm/amdgpu/userqueue: validate userptrs for userqueues")
Issue found using a prototype static analysis tool
and confirmed by code review.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
Signed-off-by: Slavin Liu <220245772@seu.edu.cn>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 2802952e4a07306da6ebe813ff1acacc5691851a)

authored by

Hongyan Xu and committed by
Alex Deucher
508babf3 4867cef0

+2 -1
+2 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
··· 1187 1187 bo = range->bo; 1188 1188 ret = amdgpu_ttm_tt_get_user_pages(bo, range); 1189 1189 if (ret) 1190 - goto unlock_all; 1190 + goto free_ranges; 1191 1191 } 1192 1192 1193 1193 invalidated = true; ··· 1214 1214 1215 1215 unlock_all: 1216 1216 drm_exec_fini(&exec); 1217 + free_ranges: 1217 1218 xa_for_each(&xa, tmp_key, range) { 1218 1219 if (!range) 1219 1220 continue;