In the case that only one of lo/hi is valid, the patching could result
in a bad address written to in FW.
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
index eb4a15db2ef2..efdebd9c0a1f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
@@ -680,6 +680,9 @@ static int amdgpu_vce_cs_reloc(struct amdgpu_cs_parser *p, 
struct amdgpu_ib *ib,
        uint64_t addr;
        int r;
 
+       if (lo >= ib->length_dw || hi >= ib->length_dw)
+               return -EINVAL;
+
        if (index == 0xffffffff)
                index = 0;
 
-- 
2.53.0

Reply via email to