Skip to contentSkip to conversation

drm/amdgpu: add check for xcp id

PATCH In review Gangliang Xie 2 participants 2 messages Jun 23

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: add check for xcp id

check sel_xcp_id before its use

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +3 -0
index 88e6eab91bc6..39416ff7386e 100644
@@ -576,6 +576,9 @@ static void amdgpu_xcp_gpu_sched_update(struct amdgpu_device *adev,
 {
 	unsigned int *num_gpu_sched;
 
+	if (sel_xcp_id >= MAX_XCP || sel_xcp_id == AMDGPU_XCP_NO_PARTITION)
+		return;
+
 	num_gpu_sched = &adev->xcp_mgr->xcp[sel_xcp_id]
 			.gpu_sched[ring->funcs->type][ring->hw_prio].num_scheds;
 	adev->xcp_mgr->xcp[sel_xcp_id].gpu_sched[ring->funcs->type][ring->hw_prio]
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Gangliang Xie

check sel_xcp_id before its use

Thanks,
Lijo

Quoted 18 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +3 -0
index 88e6eab91bc6..39416ff7386e 100644
@@ -576,6 +576,9 @@ static void amdgpu_xcp_gpu_sched_update(struct amdgpu_device *adev,
  {
  	unsigned int *num_gpu_sched;
 
+	if (sel_xcp_id >= MAX_XCP || sel_xcp_id == AMDGPU_XCP_NO_PARTITION)
+		return;
+
  	num_gpu_sched = &adev->xcp_mgr->xcp[sel_xcp_id]
  			.gpu_sched[ring->funcs->type][ring->hw_prio].num_scheds;
  	adev->xcp_mgr->xcp[sel_xcp_id].gpu_sched[ring->funcs->type][ring->hw_prio]