mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/amdgpu: Prevent debugfs nullptr dereference
@ 2026-10-27 19:35 Amadeusz Sławiński
  2026-10-27 19:35 ` [PATCH 2/2] drm/amd/display: " Amadeusz Sławiński
  0 siblings, 1 reply; 2+ messages in thread
From: Amadeusz Sławiński @ 2026-10-27 19:35 UTC (permalink / raw)
  To: dri-devel
  Cc: linux-kernel, amd-gfx, Alex Deucher, Christian König,
	David Airlie, Simona Vetter, Harry Wentland, Leo Li,
	Rodrigo Siqueira, Amadeusz Sławiński

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-27 19:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-27 19:35 [PATCH 1/2] drm/amdgpu: Prevent debugfs nullptr dereference Amadeusz Sławiński
2026-10-27 19:35 ` [PATCH 2/2] drm/amd/display: " Amadeusz Sławiński

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®