All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Chen, Xiaogang" <xiaogang.chen@amd.com>
To: Jiang Liu <gerry@linux.alibaba.com>,
	amd-gfx@lists.freedesktop.org, kent.russell@amd.com,
	shuox.liu@linux.alibaba.com
Subject: Re: [PATCH 5/6] amdgpu: fix invalid memory access in amdgpu_fence_driver_sw_fini()
Date: Thu, 2 Jan 2025 17:09:43 -0600	[thread overview]
Message-ID: <0624a755-8e5e-42ca-a694-9be40bdfdcd6@amd.com> (raw)
In-Reply-To: <4cffa8720810823b92f1a3bb484da499bc0410f8.1735795671.git.gerry@linux.alibaba.com>


On 1/1/2025 11:36 PM, Jiang Liu wrote:
> Function detects initialization status by checking sched->ops, so set
> sched->ops to non-NULL just before return in function drm_sched_init()
> to avoid possible invalid memory access on error recover path.
>
> Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
> ---
>   drivers/gpu/drm/scheduler/sched_main.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
> index 5adab4b3386c..ce2afdfc0158 100644
> --- a/drivers/gpu/drm/scheduler/sched_main.c
> +++ b/drivers/gpu/drm/scheduler/sched_main.c
> @@ -1331,6 +1331,8 @@ int drm_sched_init(struct drm_gpu_scheduler *sched,
>   	if (sched->own_submit_wq)
>   		destroy_workqueue(sched->submit_wq);
>   	drm_err(sched, "%s: Failed to setup GPU scheduler--out of memory\n", __func__);
> +	// amdgpu_fence_driver_sw_fini() checks sched->ops for status.
> +	sched->ops = NULL;

Instead change drm/scheduler how about change amdgpu driver? At 
amdgpu_device_init_schedulers if drm_sched_init fail for a ring 
scheduler set

ring->sched->op = NULL;

It is not drm issue. If drm's scheduler init fail its operation has no 
meaning, we can set it to null at amdgpu driver.

Regards

Xiaogang

>   	return -ENOMEM;
>   }
>   EXPORT_SYMBOL(drm_sched_init);
> @@ -1375,6 +1377,7 @@ void drm_sched_fini(struct drm_gpu_scheduler *sched)
>   	sched->ready = false;
>   	kfree(sched->sched_rq);
>   	sched->sched_rq = NULL;
> +	sched->ops = NULL;
>   }
>   EXPORT_SYMBOL(drm_sched_fini);
>   

  reply	other threads:[~2025-01-02 23:09 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-02  5:36 [PATCH 0/6] Fix several bugs in error handling during device Jiang Liu
2025-01-02  5:36 ` [PATCH 1/6] amdgpu: add flags to track sysfs initialization status Jiang Liu
2025-01-02 23:07   ` Chen, Xiaogang
2025-01-03 13:46     ` Russell, Kent
2025-01-03  4:04   ` Lazar, Lijo
2025-01-02  5:36 ` [PATCH 2/6] amdgpu: fix invalid memory access in kfd_cleanup_nodes() Jiang Liu
2025-01-02 23:08   ` Chen, Xiaogang
2025-01-03  2:22     ` Gerry Liu
2025-01-03  5:44       ` Chen, Xiaogang
2025-01-03  5:55         ` Gerry Liu
2025-01-03  6:19           ` Chen, Xiaogang
2025-01-03  7:05             ` Gerry Liu
2025-01-03 17:33               ` Chen, Xiaogang
2025-01-04 14:18                 ` Gerry Liu
2025-01-02  5:36 ` [PATCH 3/6] amdgpu: clear adev->in_suspend flag when fails to suspend Jiang Liu
2025-01-02  5:36 ` [PATCH 4/6] amdgpu: fix use after free bug related to amdgpu_driver_release_kms() Jiang Liu
2025-01-03  5:20   ` Lazar, Lijo
2025-01-03  5:58   ` Chen, Xiaogang
2025-01-03  7:02     ` Gerry Liu
2025-01-03  7:43       ` Shuo Liu
2025-01-03 17:34         ` Chen, Xiaogang
2025-01-04 14:21           ` Gerry Liu
2025-01-02  5:36 ` [PATCH 5/6] amdgpu: fix invalid memory access in amdgpu_fence_driver_sw_fini() Jiang Liu
2025-01-02 23:09   ` Chen, Xiaogang [this message]
2025-01-03  2:35     ` Gerry Liu
2025-01-02  5:36 ` [PATCH 6/6] amdgpu: get rid of false warnings caused by amdgpu_irq_put() Jiang Liu

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=0624a755-8e5e-42ca-a694-9be40bdfdcd6@amd.com \
    --to=xiaogang.chen@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=gerry@linux.alibaba.com \
    --cc=kent.russell@amd.com \
    --cc=shuox.liu@linux.alibaba.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 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.