summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
diff options
context:
space:
mode:
authorCe Sun <cesun102@amd.com>2026-05-18 16:44:06 +0800
committerAlex Deucher <alexander.deucher@amd.com>2026-06-04 15:24:13 -0400
commitd35617ef465b935503e4616c1ce35775a6bc1b71 (patch)
tree6ffd81aff21ec98e5a3374351eaa488296708317 /drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
parent3ea273267fd29cbf6d83ee72329f59eb5042605b (diff)
downloadlinux-next-d35617ef465b935503e4616c1ce35775a6bc1b71.tar.gz
linux-next-d35617ef465b935503e4616c1ce35775a6bc1b71.zip
drm/amdgpu: Fix user-triggerable BUG()/BUG_ON() calls
Replace BUG()/BUG_ON() with error logs and safe returns in several places where they can be triggered by invalid userspace input, preventing DoS via kernel panic. Signed-off-by: Ce Sun <cesun102@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_device.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_device.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index d2d70c4b2ac5..1dddfde91c49 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -717,7 +717,12 @@ void amdgpu_device_mm_access(struct amdgpu_device *adev, loff_t pos,
if (!drm_dev_enter(adev_to_drm(adev), &idx))
return;
- BUG_ON(!IS_ALIGNED(pos, 4) || !IS_ALIGNED(size, 4));
+ if (!IS_ALIGNED(pos, 4) || !IS_ALIGNED(size, 4)) {
+ dev_err(adev->dev, "unaligned pos/size (pos=0x%llx, size=0x%zx)\n",
+ pos, size);
+ drm_dev_exit(idx);
+ return;
+ }
spin_lock_irqsave(&adev->mmio_idx_lock, flags);
for (last = pos + size; pos < last; pos += 4) {