drm/amdgpu: fix memory overflow in the IB test
authorjsg <jsg@openbsd.org>
Thu, 14 Dec 2023 05:15:58 +0000 (05:15 +0000)
committerjsg <jsg@openbsd.org>
Thu, 14 Dec 2023 05:15:58 +0000 (05:15 +0000)
From Tim Huang
613eaee4459dfdae02f48cd02231cc177e9c37e7 in linux-6.1.y/6.1.68
6b0b7789a7a5f3e69185449f891beea58e563f9b in mainline linux

sys/dev/pci/drm/amd/amdgpu/gfx_v11_0.c
sys/dev/pci/drm/amd/amdgpu/gfx_v8_0.c
sys/dev/pci/drm/amd/amdgpu/gfx_v9_0.c

index 9f18ba9..936680e 100644 (file)
@@ -397,7 +397,7 @@ static int gfx_v11_0_ring_test_ib(struct amdgpu_ring *ring, long timeout)
                adev->wb.wb[index] = cpu_to_le32(0xCAFEDEAD);
                cpu_ptr = &adev->wb.wb[index];
 
-               r = amdgpu_ib_get(adev, NULL, 16, AMDGPU_IB_POOL_DIRECT, &ib);
+               r = amdgpu_ib_get(adev, NULL, 20, AMDGPU_IB_POOL_DIRECT, &ib);
                if (r) {
                        DRM_ERROR("amdgpu: failed to get ib (%ld).\n", r);
                        goto err1;
index f6d7381..c900a5a 100644 (file)
@@ -883,8 +883,8 @@ static int gfx_v8_0_ring_test_ib(struct amdgpu_ring *ring, long timeout)
        gpu_addr = adev->wb.gpu_addr + (index * 4);
        adev->wb.wb[index] = cpu_to_le32(0xCAFEDEAD);
        memset(&ib, 0, sizeof(ib));
-       r = amdgpu_ib_get(adev, NULL, 16,
-                                       AMDGPU_IB_POOL_DIRECT, &ib);
+
+       r = amdgpu_ib_get(adev, NULL, 20, AMDGPU_IB_POOL_DIRECT, &ib);
        if (r)
                goto err1;
 
index 9ec5794..277c766 100644 (file)
@@ -1034,8 +1034,8 @@ static int gfx_v9_0_ring_test_ib(struct amdgpu_ring *ring, long timeout)
        gpu_addr = adev->wb.gpu_addr + (index * 4);
        adev->wb.wb[index] = cpu_to_le32(0xCAFEDEAD);
        memset(&ib, 0, sizeof(ib));
-       r = amdgpu_ib_get(adev, NULL, 16,
-                                       AMDGPU_IB_POOL_DIRECT, &ib);
+
+       r = amdgpu_ib_get(adev, NULL, 20, AMDGPU_IB_POOL_DIRECT, &ib);
        if (r)
                goto err1;