From nobody Wed Jun 17 04:04:27 2026 Received: from mail-m49198.qiye.163.com (mail-m49198.qiye.163.com [45.254.49.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E8053DA7ED for ; Wed, 22 Apr 2026 12:34:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.49.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776861267; cv=none; b=D7P4zyMl4/VP/mxlWr+ovWMTJMXkOI6u3GmHjV9BvRdI8kcj2Wdnr7GzzkpuHTAWkg44kFi3WvTfquOHSrYXseCMOyjCpErOq1L84DI6ASbH0052Y6qSbWH4jS0rfGUKTXNXaRi3sGCoTHpKt8ELG4Zlk9c/nTi9mjOc/7ZiAVc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776861267; c=relaxed/simple; bh=Zn5ADCYGw/jxUXnSyMAVoH6qXFNb93IxcQFspGqNo6c=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=B0KI+/TgoKdCCCnSV0SsVOqSxyAofVzjkOYi+Fyj4ldso4evVrwZb+u6bgpR6SfTbBhZc3AWkWOniSM8YIOYo4s+4TpaP4rlB0JxvE1So36UFfK8tLn4Zx8BzchkNOqa34KWAMvoyzvGWlhYorgXGCVyvkiDzKgBtn2aNnQ2DkU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=seu.edu.cn; spf=pass smtp.mailfrom=seu.edu.cn; dkim=pass (1024-bit key) header.d=seu.edu.cn header.i=@seu.edu.cn header.b=DGB5GnCA; arc=none smtp.client-ip=45.254.49.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=seu.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=seu.edu.cn Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=seu.edu.cn header.i=@seu.edu.cn header.b="DGB5GnCA" Received: from LAPTOP-99KJFSET (unknown [112.10.250.117]) by smtp.qiye.163.com (Hmail) with ESMTP id 3bb9ba4ed; Wed, 22 Apr 2026 20:34:04 +0800 (GMT+08:00) From: hongyan Xu To: alexander.deucher@amd.com Cc: christian.koenig@amd.com, airlied@gmail.com, simona@ffwll.ch, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, jianhao.xu@seu.edu.cn, 220245772@seu.edu.cn, Hongyan Xu Subject: [PATCH] drm/amdgpu: avoid double drm_exec_fini() in userq validate Date: Wed, 22 Apr 2026 20:34:03 +0800 Message-ID: <20260422123403.687-1-getshell@seu.edu.cn> X-Mailer: git-send-email 2.50.1.windows.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-HM-Tid: 0a9db52ee67903a1kunm83803f50211c X-HM-MType: 10 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlCSR5IVkwZSEJLQkhOSU9DTVYeHw5VEwETFhoSFy QUDg9ZV1kYEgtZQVlKSklVSktVSU5LVUpKTFlXWRYaDxIVHRRZQVlLVUtVS1VLWQY+ DKIM-Signature: a=rsa-sha256; b=DGB5GnCARtgbnj2KhZobD2E3DLO/TKyLNfs4T28k+VNJBx/HJpaPfEVy1lVMIYWDmdIlcJCFcbIVTpz6c4+OWeiXiUtjH93gQXbXnuczZddtAPS2nkatGlL5hrh3QH8hBVI0qa5AQDifpDy3TWhqEVnOILHIFTyjVppuOdfSxK4=; c=relaxed/relaxed; s=default; d=seu.edu.cn; v=1; bh=84s310TWTqSx7MXOEnP4lMe1uc8jCndi4Sots2rPfpo=; h=date:mime-version:subject:message-id:from; Content-Type: text/plain; charset="utf-8" From: Hongyan Xu 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 userqueue= s") Issue found using a prototype static analysis tool and confirmed by code review. Signed-off-by: Hongyan Xu --- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/am= d/amdgpu/amdgpu_userq.c index 9d67b770bcc2..fe49108fabbd 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c @@ -1193,7 +1193,7 @@ amdgpu_userq_vm_validate(struct amdgpu_userq_mgr *uq_= mgr) bo =3D range->bo; ret =3D amdgpu_ttm_tt_get_user_pages(bo, range); if (ret) - goto unlock_all; + goto free_ranges; } =20 invalidated =3D true; @@ -1220,6 +1220,7 @@ amdgpu_userq_vm_validate(struct amdgpu_userq_mgr *uq_= mgr) =20 unlock_all: drm_exec_fini(&exec); +free_ranges: xa_for_each(&xa, tmp_key, range) { if (!range) continue; --=20 2.50.1.windows.1