From: "Christian König" <christian.koenig@amd.com>
To: "Zhang, Jesse(Jie)" <Jesse.Zhang@amd.com>,
Alex Deucher <alexdeucher@gmail.com>
Cc: "amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>,
"Deucher, Alexander" <Alexander.Deucher@amd.com>,
"Khatri, Sunil" <Sunil.Khatri@amd.com>
Subject: Re: [PATCH 2/2] drm/amdgpu: don't unreserve the freed root PD in amdgpu_vm_init()
Date: Fri, 20 Nov 2026 13:00:53 +0100 [thread overview]
Message-ID: <011ecfb0-b130-4f9a-a67c-3391d651d207@amd.com> (raw)
In-Reply-To: <DM4PR12MB515233FDF2622F0116CB7ABDE3792@DM4PR12MB5152.namprd12.prod.outlook.com>
On 11/20/26 00:43, Zhang, Jesse(Jie) wrote:
> AMD General
>
>> -----Original Message-----
>> From: Alex Deucher <alexdeucher@gmail.com>
>> Sent: Thursday, November 19, 2026 11:54 PM
>> To: Koenig, Christian <Christian.Koenig@amd.com>
>> Cc: Zhang, Jesse(Jie) <Jesse.Zhang@amd.com>; amd-
>> gfx@lists.freedesktop.org; Deucher, Alexander
>> <Alexander.Deucher@amd.com>; Khatri, Sunil <Sunil.Khatri@amd.com>
>> Subject: Re: [PATCH 2/2] drm/amdgpu: don't unreserve the freed root PD in
>> amdgpu_vm_init()
>>
>> On Thu, Nov 19, 2026 at 9:56 AM Christian König
>> <christian.koenig@amd.com> wrote:
>>>
>>>
>>>
>>> On 11/19/26 10:56, Jesse Zhang wrote:
>>>> The error path of amdgpu_vm_init() frees the root PD, which clears
>>>> vm->root.bo, and then unreserves vm->root.bo. On navi48, with an
>>>> allocation after reserving the root PD failing through failslab
>>>> while opening the render node:
>>>>
>>>> Oops: general protection fault, probably for non-canonical address
>> 0xdffffc000000005e: 0000 [#1] SMP KASAN NOPTI
>>>> KASAN: null-ptr-deref in range [0x00000000000002f0-
>> 0x00000000000002f7]
>>>> RIP: 0010:amdgpu_vm_init+0xa9f/0x1480 [amdgpu]
>>>> amdgpu_driver_open_kms+0x2b1/0xd10 [amdgpu]
>>>> drm_file_alloc+0x58f/0xac0 [drm]
>>>> drm_open_helper+0x1b3/0x4b0 [drm]
>>>>
>>>> Unreserve it through root_bo, which still holds a reference. With
>>>> this and the entity fix 4842 opens with allocations failing in turn
>>>> don't oops anymore.
>>>>
>>>> Fixes: 8473bfdcb5b1 ("drm/amdgpu: fix error handling in
>>>> amdgpu_vm_init")
>>>> Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
>>>
>>> That is already fixed with:
>>>
>>> commit 26401a4999f1596a515b2e704e7066ac09306488
>>> Author: Christian König <ckoenig.leichtzumerken@gmail.com>
>>> Date: Wed Oct 7 14:46:57 2026 +0200
>>>
>>> drm/exec: don't immediately add prelocked obj to array of locked
>>> objs
>>>
>>
>> If this is missing from ASDN, feel free to cherry-pick.
>
> Hi Christian, Alex,
>
> Thanks. As far as I can see, 26401a4999f1 ("drm/exec: don't immediately
> add prelocked obj to array of locked objs") only changes drm_exec and
> doesn't touch the amdgpu_vm_init() error path.
Sorry that was my fault I replied to the wrong mail.
The patch 26401a4999f1 ("drm/exec: don't immediately add prelocked obj to array of locked objs") fixes the issue patch #1 in this series tries to address and not patch #2.
So yeah patch #2 is perfectly correct, but we should just cherry pick the drm/exec fix into amd-staging-drm-next, going to take a look at that today.
Thanks,
Christian.
>
> The same fix as this patch landed in amd-staging-drm-next yesterday:
>
> 768e106833a9 ("drm/amdgpu: fix NULL deref in error path")
>
> from Pierre-Eric, so please drop this patch. I'll cherry-pick
> 768e106833a9 to amd-unified-interface,
>
> Thanks
> Jesse
>>
>> Alex
>>
>>>
>>> Regards,
>>> Christian
>>>
>>>> ---
>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++-
>>>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>>>> index 8cc5964f29c0..272eac0ef317 100644
>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>>>> @@ -2718,8 +2718,9 @@ int amdgpu_vm_init(struct amdgpu_device
>> *adev, struct amdgpu_vm *vm,
>>>> return 0;
>>>>
>>>> error_free_root:
>>>> + /* This clears vm->root.bo, root_bo keeps the BO alive */
>>>> amdgpu_vm_pt_free_root(adev, vm);
>>>> - amdgpu_bo_unreserve(vm->root.bo);
>>>> + amdgpu_bo_unreserve(root_bo);
>>>> amdgpu_bo_unref(&root_bo);
>>>>
>>>> error_free_delayed:
>>>
next prev parent reply other threads:[~2026-11-20 12:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 9:56 [PATCH 1/2] drm/amdgpu: reserve a fence slot before adding the eviction fence Jesse Zhang
2026-11-19 9:56 ` [PATCH 2/2] drm/amdgpu: don't unreserve the freed root PD in amdgpu_vm_init() Jesse Zhang
2026-11-19 14:46 ` Christian König
2026-11-19 15:54 ` Alex Deucher
2026-11-19 23:43 ` Zhang, Jesse(Jie)
2026-11-20 12:00 ` Christian König [this message]
2026-11-19 10:13 ` [PATCH 1/2] drm/amdgpu: reserve a fence slot before adding the eviction fence sashiko-bot
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=011ecfb0-b130-4f9a-a67c-3391d651d207@amd.com \
--to=christian.koenig@amd.com \
--cc=Alexander.Deucher@amd.com \
--cc=Jesse.Zhang@amd.com \
--cc=Sunil.Khatri@amd.com \
--cc=alexdeucher@gmail.com \
--cc=amd-gfx@lists.freedesktop.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.