Skip to content

Commit 2161e09

Browse files
Lu Yaoalexdeucher
authored andcommitted
drm/amdgpu: Fix cat debugfs amdgpu_regs_didt causes kernel null pointer
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 <[email protected]> Signed-off-by: Lu Yao <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 6967741 commit 2161e09

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,9 @@ static ssize_t amdgpu_debugfs_regs_didt_read(struct file *f, char __user *buf,
638638
if (size & 0x3 || *pos & 0x3)
639639
return -EINVAL;
640640

641+
if (!adev->didt_rreg)
642+
return -EOPNOTSUPP;
643+
641644
r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
642645
if (r < 0) {
643646
pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
@@ -694,6 +697,9 @@ static ssize_t amdgpu_debugfs_regs_didt_write(struct file *f, const char __user
694697
if (size & 0x3 || *pos & 0x3)
695698
return -EINVAL;
696699

700+
if (!adev->didt_wreg)
701+
return -EOPNOTSUPP;
702+
697703
r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
698704
if (r < 0) {
699705
pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);

0 commit comments

Comments
 (0)