From: "Amadeusz Sławiński" <amade@asmblr.net>
To: dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org,
"Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Harry Wentland" <harry.wentland@amd.com>,
"Leo Li" <sunpeng.li@amd.com>,
"Rodrigo Siqueira" <siqueira@igalia.com>,
"Amadeusz Sławiński" <amade@asmblr.net>
Subject: [PATCH 1/2] drm/amdgpu: Prevent debugfs nullptr dereference
Date: Tue, 27 Oct 2026 20:35:58 +0100 [thread overview]
Message-ID: <20261027193559.28474-1-amade@asmblr.net> (raw)
Running
cat /sys/kernel/debug/dri/0/psp_spirom_dump
with amdgpu card that doesn't support it leads to nullptr dereference.
Add checks to prevent that.
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 6 ++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 82a2684dbd2e..627c74f16914 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -5381,6 +5381,9 @@ static int psp_read_spirom_debugfs_open(struct inode *inode, struct file *filp)
struct spirom_bo *bo_triplet;
int ret;
+ if (!adev->psp.funcs || !adev->psp.funcs->dump_spirom)
+ return -EOPNOTSUPP;
+
/* serialize the open() file calling */
if (!mutex_trylock(&adev->psp.mutex))
return -EBUSY;
@@ -5473,6 +5476,9 @@ void amdgpu_psp_debugfs_init(struct amdgpu_device *adev)
#if defined(CONFIG_DEBUG_FS)
struct drm_minor *minor = adev_to_drm(adev)->primary;
+ if (!adev->psp.funcs || !adev->psp.funcs->dump_spirom)
+ return;
+
debugfs_create_file_size("psp_spirom_dump", 0444, minor->debugfs_root,
adev, &psp_dump_spirom_debugfs_ops, AMD_VBIOS_FILE_MAX_SIZE_B * 2);
#endif
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index a4ec60f6c317..975d12359358 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -574,7 +574,7 @@ struct amdgpu_psp_funcs {
(psp)->funcs->update_spirom((psp), fw_pri_mc_addr) : -EINVAL)
#define psp_dump_spirom(psp, fw_pri_mc_addr) \
- ((psp)->funcs->dump_spirom ? \
+ (((psp)->funcs && (psp)->funcs->dump_spirom) ? \
(psp)->funcs->dump_spirom((psp), fw_pri_mc_addr) : -EINVAL)
#define psp_vbflash_status(psp) \
base-commit: 83f32c773255720a661aa45d83e36278135f23f5
--
2.56.0
next reply other threads:[~2026-10-27 19:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 19:35 Amadeusz Sławiński [this message]
2026-10-27 19:35 ` [PATCH 2/2] drm/amd/display: " Amadeusz Sławiński
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=20261027193559.28474-1-amade@asmblr.net \
--to=amade@asmblr.net \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=harry.wentland@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=siqueira@igalia.com \
--cc=sunpeng.li@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
all inboxes | Powered by JetHome®