From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: "Lu Yao" <yaolu@kylinos.cn>,
"Christian König" <christian.koenig@amd.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Sasha Levin" <sashal@kernel.org>,
Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch,
shashank.sharma@amd.com, Hawking.Zhang@amd.com,
srinivasan.shanmugam@amd.com, victorchengchi.lu@amd.com,
Praful.Swarnakar@amd.com, le.ma@amd.com, tom.stdenis@amd.com,
andrealmeid@igalia.com, amd-gfx@lists.freedesktop.org,
dri-devel@lists.freedesktop.org
Subject: [PATCH AUTOSEL 5.15 09/10] drm/amdgpu: Fix cat debugfs amdgpu_regs_didt causes kernel null pointer
Date: Mon, 4 Dec 2023 15:36:06 -0500 [thread overview]
Message-ID: <20231204203616.2094529-9-sashal@kernel.org> (raw)
In-Reply-To: <20231204203616.2094529-1-sashal@kernel.org>
From: Lu Yao <yaolu@kylinos.cn>
[ Upstream commit 2161e09cd05a50d80736fe397145340d2e8f6c05 ]
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.
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Lu Yao <yaolu@kylinos.cn>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
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 beb199d13451b..632d8df04ef45 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
@@ -342,6 +342,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)
+ return -EOPNOTSUPP;
+
r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
if (r < 0) {
pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
@@ -401,6 +404,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)
+ return -EOPNOTSUPP;
+
r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
if (r < 0) {
pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
--
2.42.0
next prev parent reply other threads:[~2023-12-04 20:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-04 20:35 [PATCH AUTOSEL 5.15 01/10] pinctrl: lochnagar: Don't build on MIPS Sasha Levin
2023-12-04 20:35 ` [PATCH AUTOSEL 5.15 02/10] ALSA: hda - Fix speaker and headset mic pin config for CHUWI CoreBook XPro Sasha Levin
2023-12-04 20:36 ` [PATCH AUTOSEL 5.15 03/10] ksmbd: don't update ->op_state as OPLOCK_STATE_NONE on error Sasha Levin
2023-12-04 20:36 ` [PATCH AUTOSEL 5.15 04/10] mptcp: fix uninit-value in mptcp_incoming_options Sasha Levin
2023-12-04 20:36 ` [PATCH AUTOSEL 5.15 05/10] wifi: cfg80211: lock wiphy mutex for rfkill poll Sasha Levin
2023-12-04 20:36 ` [PATCH AUTOSEL 5.15 06/10] debugfs: fix automount d_fsdata usage Sasha Levin
2023-12-04 20:36 ` [PATCH AUTOSEL 5.15 07/10] debugfs: annotate debugfs handlers vs. removal with lockdep Sasha Levin
2023-12-04 20:36 ` [PATCH AUTOSEL 5.15 08/10] debugfs: add API to allow debugfs operations cancellation Sasha Levin
2023-12-04 20:36 ` Sasha Levin [this message]
2023-12-04 20:36 ` [PATCH AUTOSEL 5.15 10/10] nvme-core: check for too small lba shift Sasha Levin
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=20231204203616.2094529-9-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=Hawking.Zhang@amd.com \
--cc=Praful.Swarnakar@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=andrealmeid@igalia.com \
--cc=christian.koenig@amd.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=le.ma@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=shashank.sharma@amd.com \
--cc=srinivasan.shanmugam@amd.com \
--cc=stable@vger.kernel.org \
--cc=tom.stdenis@amd.com \
--cc=victorchengchi.lu@amd.com \
--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