From: "Christian König" <christian.koenig@amd.com>
To: Lu Yao <yaolu@kylinos.cn>, airlied@gmail.com, daniel@ffwll.ch
Cc: alexander.deucher@amd.com, amd-gfx@lists.freedesktop.org,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] drm/amdgpu: Fix cat debugfs amdgpu_regs_didt causes kernel null pointer
Date: Thu, 23 Nov 2023 09:11:46 +0100 [thread overview]
Message-ID: <80ea6067-c531-4765-8576-265e565525fa@amd.com> (raw)
In-Reply-To: <20231123012234.5783-1-yaolu@kylinos.cn>
Am 23.11.23 um 02:22 schrieb Lu Yao:
> For 'AMDGPU_FAMILY_SI' family cards, in 'si_common_early_init' func, init
> 'didt_rreg' and 'didt_wreg' to 'NULL'. But in func
> 'amdgpu_debugfs_regs_didt_read/write', using 'RREG32_DIDT' 'WREG32_DIDT'
> lacks of relevant judgment. And other 'amdgpu_ip_block_version' that use
> these two definitions won't be added for 'AMDGPU_FAMILY_SI'.
>
> So, add null pointer judgment before calling.
>
> Signed-off-by: Lu Yao <yaolu@kylinos.cn>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> Changes in v2:
> 1. Drop dev_err message.
> 2. Change error code from 'EPERM' to 'EOPNOTSUPP'
> Link to v1: https://lore.kernel.org/all/20231122093509.34302-1-yaolu@kylinos.cn/
> Thanks Christian for his comments.
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> index a53f436fa9f1..e098cd66fa2a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> @@ -638,6 +638,9 @@ static ssize_t amdgpu_debugfs_regs_didt_read(struct file *f, char __user *buf,
> if (size & 0x3 || *pos & 0x3)
> return -EINVAL;
>
> + if (adev->didt_rreg == NULL)
> + return -EOPNOTSUPP;
> +
> r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
> if (r < 0) {
> pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
> @@ -694,6 +697,9 @@ static ssize_t amdgpu_debugfs_regs_didt_write(struct file *f, const char __user
> if (size & 0x3 || *pos & 0x3)
> return -EINVAL;
>
> + if (adev->didt_wreg == NULL)
> + return -EOPNOTSUPP;
> +
> r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
> if (r < 0) {
> pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
next prev parent reply other threads:[~2023-11-23 8:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-22 9:35 [PATCH] drm/amdgpu: Fix cat debugfs amdgpu_regs_didt causes kernel null pointer Lu Yao
2023-11-22 11:26 ` Christian König
2023-11-23 1:22 ` [PATCH v2] " Lu Yao
2023-11-23 8:11 ` Christian König [this message]
2023-11-27 22:20 ` Alex Deucher
2023-11-24 13:19 ` [PATCH] " kernel test robot
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=80ea6067-c531-4765-8576-265e565525fa@amd.com \
--to=christian.koenig@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=yaolu@kylinos.cn \
/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