From: "Christian König" <christian.koenig@amd.com>
To: Jiang Liu <gerry@linux.alibaba.com>,
alexander.deucher@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com,
simona@ffwll.ch, sunil.khatri@amd.com, lijo.lazar@amd.com,
Hawking.Zhang@amd.com, mario.limonciello@amd.com,
xiaogang.chen@amd.com, Kent.Russell@amd.com,
shuox.liu@linux.alibaba.com, amd-gfx@lists.freedesktop.org
Subject: Re: [v4 5/5] drm/amdgpu: fix invalid memory access in amdgpu_fence_driver_sw_fini()
Date: Fri, 10 Jan 2025 07:51:50 +0100 [thread overview]
Message-ID: <098f1b68-4772-481b-9b50-864d9cd2ad8a@amd.com> (raw)
In-Reply-To: <b824d12a9636ac43066d731c514de8abbf1d115e.1736474822.git.gerry@linux.alibaba.com>
Am 10.01.25 um 03:08 schrieb Jiang Liu:
> Function detects initialization status by checking sched->ops, so set
> sched->ops to non-NULL just before return in function
> amdgpu_fence_driver_sw_fini() and amdgpu_device_init_schedulers()
> to avoid possible invalid memory access on error recover path.
>
> Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 +
> drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 4 +++-
> 2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index f29a4ad3c6d0..3688e9eb949b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -2857,6 +2857,7 @@ static int amdgpu_device_init_schedulers(struct amdgpu_device *adev)
> if (r) {
> DRM_ERROR("Failed to create scheduler on ring %s.\n",
> ring->name);
> + ring->sched.ops = NULL;
> return r;
> }
> r = amdgpu_uvd_entity_init(adev, ring);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> index 2f24a6aa13bf..b5e87b515139 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> @@ -656,8 +656,10 @@ void amdgpu_fence_driver_sw_fini(struct amdgpu_device *adev)
> * The natural check would be sched.ready, which is
> * set as drm_sched_init() finishes...
> */
> - if (ring->sched.ops)
> + if (ring->sched.ops) {
> drm_sched_fini(&ring->sched);
> + ring->sched.ops = NULL;
> + }
As said in my previous reply we should really stop checking sched.ops here.
The scheduler should not be cleaned up by this function in the first place.
Regards,
Christian.
>
> for (j = 0; j <= ring->fence_drv.num_fences_mask; ++j)
> dma_fence_put(ring->fence_drv.fences[j]);
next prev parent reply other threads:[~2025-01-10 6:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-10 2:08 [v4 0/6] Fix several bugs in error handling during device probe Jiang Liu
2025-01-10 2:08 ` [v4 1/5] drm/amdgpu: clear adev->in_suspend flag when fails to suspend Jiang Liu
2025-01-10 18:57 ` Mario Limonciello
2025-01-14 3:12 ` Gerry Liu
2025-01-10 2:08 ` [v4 2/5] drm/amdxcp: introduce new API amdgpu_xcp_drm_dev_free() Jiang Liu
2025-01-10 19:02 ` Mario Limonciello
2025-01-13 4:40 ` Lazar, Lijo
2025-01-10 2:08 ` [v4 3/5] drm/amdgpu: fix use after free bug related to amdgpu_driver_release_kms() Jiang Liu
2025-01-10 19:03 ` Mario Limonciello
2025-01-10 2:08 ` [v4 4/5] drm/amdgpu: enhance error handling in function amdgpu_pci_probe() Jiang Liu
2025-01-10 19:05 ` Mario Limonciello
2025-01-10 2:08 ` [v4 5/5] drm/amdgpu: fix invalid memory access in amdgpu_fence_driver_sw_fini() Jiang Liu
2025-01-10 6:51 ` Christian König [this message]
2025-01-10 7:37 ` Gerry Liu
2025-01-10 8:19 ` Christian König
2025-01-10 19:06 ` [v4 0/6] Fix several bugs in error handling during device probe Mario Limonciello
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=098f1b68-4772-481b-9b50-864d9cd2ad8a@amd.com \
--to=christian.koenig@amd.com \
--cc=Hawking.Zhang@amd.com \
--cc=Kent.Russell@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=gerry@linux.alibaba.com \
--cc=lijo.lazar@amd.com \
--cc=mario.limonciello@amd.com \
--cc=shuox.liu@linux.alibaba.com \
--cc=simona@ffwll.ch \
--cc=sunil.khatri@amd.com \
--cc=xiaogang.chen@amd.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