drm/amdgpu: Fix warnings
authorLijo Lazar <lijo.lazar@amd.com>
Tue, 23 May 2023 07:56:39 +0000 (13:26 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 9 Jun 2023 14:56:58 +0000 (10:56 -0400)
Fix warnings reported by kernel test bot/smatch

smatch warnings:
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c:65 amdgpu_xcp_run_transition()
error: buffer overflow 'xcp_mgr->xcp' 8 <= 8

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Link: https://lore.kernel.org/r/202305231453.I0bXngYn-lkp@intel.com/
Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c

index e9586a0..fcdc086 100644 (file)
@@ -65,7 +65,7 @@ static int amdgpu_xcp_run_transition(struct amdgpu_xcp_mgr *xcp_mgr, int xcp_id,
        struct amdgpu_xcp *xcp;
        int i, ret;
 
-       if (xcp_id > MAX_XCP || !xcp_mgr->xcp[xcp_id].valid)
+       if (xcp_id >= MAX_XCP || !xcp_mgr->xcp[xcp_id].valid)
                return -EINVAL;
 
        xcp = &xcp_mgr->xcp[xcp_id];