From nobody Wed Jun 17 04:03:53 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 DC3E23DEAFD for ; Wed, 22 Apr 2026 12:38:21 +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=1776861505; cv=none; b=hxKa6EvXpIU37qWBwV2titMrC1ri28tWPzV8BUqqRU8loa3a3Qbfa5hyXxUlWenA+0zLIv4i9uOrXms5i2zEuPIxIN03oMgfHfct2KM9TsFGuQVHIkcWRVpCN3ETPgmw7Va3S/3aj6TVB8ldIOm+Stn6Ovwk/rUMlyM/YyP3QLo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776861505; c=relaxed/simple; bh=EbckTp0dnl14TNMFl7d8go33RmowV6tmUrv21nnxB7w=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=HnYIwjSZ5Xb/nJmEgv9XjyIa6mV7KbYfYF0LFy3ifeslN5r7rQ36msXiTgJB622WHj3H9SI+PckzMUvrvi2hi1Tm7qPwJNIIMSZfsVRwl535VapkuAtHN8VB3z7CQ4DIHsASfB2j36KzGAnhZ+gH9/s39Yjr1n3bplSEy1cZglg= 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=lZspk4wK; 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="lZspk4wK" Received: from LAPTOP-99KJFSET (unknown [112.10.250.117]) by smtp.qiye.163.com (Hmail) with ESMTP id 3bb9ba587; Wed, 22 Apr 2026 20:38:17 +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:38:17 +0800 Message-ID: <20260422123817.1940-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: 0a9db532c6f903a1kunm7eb60d492426 X-HM-MType: 10 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlCGk8YVhhDSExDTBhKGUMeGFYeHw5VEwETFhoSFy QUDg9ZV1kYEgtZQVlKSklVSktVSU5LVUpKTFlXWRYaDxIVHRRZQVlLVUtVS1VLWQY+ DKIM-Signature: a=rsa-sha256; b=lZspk4wK6YMyq6qyPLONzxsl2WFyxmfrochGEfwUZ/wExadUb+d1bPBVISU1RMDNZoED+GN6oOzU+crna3dlDWr7s8dsf7MrmMF4Z0k6Uq0gFzLWTIUm1l4rlzoqgdA+0C9fiHmAi8tjpwJBK8LY6YcZ68zRbFS6+NwGQ3HvwlY=; c=relaxed/relaxed; s=default; d=seu.edu.cn; v=1; bh=dfYTW/RukwJufC/jwZrraJiVVcRI03xOMxKQGV1Op4Y=; h=date:mime-version:subject:message-id:from; Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Slavin Liu <220245772@seu.edu.cn> --- 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