Skip to contentSkip to conversation

drm/amdgpu: bounds check xcp ip block index

PATCH In review Lijo Lazar 2 participants 2 messages Jun 18

Subsystems (2)
lore
Share & tools
lore

Lijo Lazar

author
#0 lore raw

PATCH 1/1 drm/amdgpu: bounds check xcp ip block index

Check out of range values for ip block.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +2 -1
index d0d494e00cfe..88e6eab91bc6 100644
@@ -381,7 +381,8 @@ int amdgpu_xcp_get_inst_details(struct amdgpu_xcp *xcp,
 				enum AMDGPU_XCP_IP_BLOCK ip,
 				uint32_t *inst_mask)
 {
-	if (!xcp->valid || !inst_mask || !(xcp->ip[ip].valid))
+	if (!xcp->valid || !inst_mask || ip >= AMDGPU_XCP_MAX_BLOCKS ||
+	    !(xcp->ip[ip].valid))
 		return -EINVAL;
 
 	*inst_mask = xcp->ip[ip].inst_mask;
Signature · 1 line
2.49.0
Reviewed-by on v1 1/1
#1 lore raw

AMD General

Thanks & Regards
Asad

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, June 18, 2026 10:46 AM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Kamal, Asad <[email protected]>; Li, Candice <[email protected]>
Subject: [PATCH] drm/amdgpu: bounds check xcp ip block index

Check out of range values for ip block.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +2 -1
index d0d494e00cfe..88e6eab91bc6 100644
@@ -381,7 +381,8 @@ int amdgpu_xcp_get_inst_details(struct amdgpu_xcp *xcp,
                                enum AMDGPU_XCP_IP_BLOCK ip,
                                uint32_t *inst_mask)
 {
-       if (!xcp->valid || !inst_mask || !(xcp->ip[ip].valid))
+       if (!xcp->valid || !inst_mask || ip >= AMDGPU_XCP_MAX_BLOCKS ||
+           !(xcp->ip[ip].valid))
                return -EINVAL;
 
        *inst_mask = xcp->ip[ip].inst_mask;

--
2.49.0