drm/amdgpu: Fix a null pointer access when the smc_rreg pointer is NULL
authorjsg <jsg@openbsd.org>
Thu, 30 Nov 2023 02:37:03 +0000 (02:37 +0000)
committerjsg <jsg@openbsd.org>
Thu, 30 Nov 2023 02:37:03 +0000 (02:37 +0000)
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

index de61a85..fd79657 100644 (file)
@@ -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;