From: "Christian König" <christian.koenig@amd.com>
To: Yang Zi <2959243019@qq.com>, alexander.deucher@amd.com
Cc: airlied@gmail.com, "Simona Vetter" <simona@ffwll.ch>,
"Sunil Khatri" <sunil.khatri@amd.com>,
"Prike Liang" <Prike.Liang@amd.com>,
"Timur Kristóf" <timur.kristof@gmail.com>,
"Pierre-Eric Pelloux-Prayer" <pierre-eric.pelloux-prayer@amd.com>,
"Mikhail Gavrilov" <mikhail.v.gavrilov@gmail.com>,
"Srinivasan Shanmugam" <srinivasan.shanmugam@amd.com>,
"Natalie Vock" <nat@pixelcluster.dev>,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/amdgpu: fix NULL pointer dereference in amdgpu_vm_init error path
Date: Wed, 26 Aug 2026 11:41:46 +0200 [thread overview]
Message-ID: <f2e876c6-640b-4572-9c7e-cb9961f986e4@amd.com> (raw)
In-Reply-To: <tencent_FA0B5EEC37B4CAFBE12C77A63D352E5BDD05@qq.com>
On 8/25/26 11:29, Yang Zi wrote:
> In amdgpu_vm_init(), the error_free_root cleanup label runs
> amdgpu_vm_pt_free_root() before amdgpu_bo_unreserve(). However,
> amdgpu_vm_pt_free_root() walks the page table tree and frees each
> entry via amdgpu_vm_pt_free(), which calls amdgpu_bo_unref() on the
> root BO and clears vm->root.bo to NULL. The subsequent
> amdgpu_bo_unreserve(vm->root.bo) then dereferences a NULL pointer.
>
> Swap the two statements so that the root BO is unreserved before it is
> freed. This mirrors the success path at the end of the function, which
> unreserves before releasing its reference.
>
> Found by static analysis of the error handling path; the failure cases
> (dma_resv_reserve_fences() or amdgpu_vm_pt_clear() returning an error)
> trigger this path.
>
> Signed-off-by: Yang Zi <2959243019@qq.com>
> ---
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index d2ad5b0e8759..dc72181ea0fa 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -2672,8 +2672,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
> return 0;
>
> error_free_root:
> - amdgpu_vm_pt_free_root(adev, vm);
> amdgpu_bo_unreserve(vm->root.bo);
> + amdgpu_vm_pt_free_root(adev, vm);
Clear NAK, that is just nonsense and will potentially trigger tons of warnings.
The amdgpu_bo_unreserve(() call just needs to use the local variable root_bo instead.
Regards,
Christian.
> amdgpu_bo_unref(&root_bo);
>
> error_free_delayed:
>
next prev parent reply other threads:[~2026-08-26 9:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 9:29 Yang Zi
2026-08-26 9:41 ` Christian König [this message]
2026-08-25 9:36 Yang Zi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f2e876c6-640b-4572-9c7e-cb9961f986e4@amd.com \
--to=christian.koenig@amd.com \
--cc=2959243019@qq.com \
--cc=Prike.Liang@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mikhail.v.gavrilov@gmail.com \
--cc=nat@pixelcluster.dev \
--cc=pierre-eric.pelloux-prayer@amd.com \
--cc=simona@ffwll.ch \
--cc=srinivasan.shanmugam@amd.com \
--cc=sunil.khatri@amd.com \
--cc=timur.kristof@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®