From 9bc9405e5f5c2583f4b3f68873465c21f232a968 Mon Sep 17 00:00:00 2001 From: jsg Date: Thu, 30 Nov 2023 02:37:03 +0000 Subject: [PATCH] drm/amdgpu: Fix a null pointer access when the smc_rreg pointer is NULL From Qu Huang 6c1b3d89a2dda79881726bb6e37af19c0936d736 in linux-6.1.y/6.1.64 5104fdf50d326db2c1a994f8b35dcd46e63ae4ad in mainline linux --- sys/dev/pci/drm/amd/amdgpu/amdgpu_debugfs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_debugfs.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_debugfs.c index de61a85c4b0..fd796574f87 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_debugfs.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_debugfs.c @@ -589,6 +589,9 @@ static ssize_t amdgpu_debugfs_regs_smc_read(struct file *f, char __user *buf, ssize_t result = 0; int r; + if (!adev->smc_rreg) + return -EPERM; + if (size & 0x3 || *pos & 0x3) return -EINVAL; @@ -645,6 +648,9 @@ static ssize_t amdgpu_debugfs_regs_smc_write(struct file *f, const char __user * ssize_t result = 0; int r; + if (!adev->smc_wreg) + return -EPERM; + if (size & 0x3 || *pos & 0x3) return -EINVAL; -- 2.20.1