Skip to contentSkip to conversation

drm/amdgpu: validate XCP topology counts before division

PATCH In review Asad Kamal 2 participants 2 messages Jun 18

Subsystems (2)
lore
Share & tools
lore

Asad Kamal

author
#0 lore raw

PATCH v2 1/1 drm/amdgpu: validate XCP topology counts before division

In aqua_vanjaram_get_xcp_res_info(), max_res[i] can be zero. When res_lt_xcp is true the code divides num_xcp by max_res[i], causing a divide fault.

Skip the loop body for absent resources.

v2: Remove redundant checks (Lijo)

---
 drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c +3 -1
index 72ea37dbfea8..1c11cc280599 100644
@@ -273,8 +273,10 @@ static int aqua_vanjaram_get_xcp_res_info(struct amdgpu_xcp_mgr *xcp_mgr,
 	xcp_cfg->num_res = ARRAY_SIZE(max_res);
 
 	for (i = 0; i < xcp_cfg->num_res; i++) {
-		res_lt_xcp = max_res[i] < num_xcp;
 		xcp_cfg->xcp_res[i].id = i;
+		if (!max_res[i])
+			continue;
+		res_lt_xcp = max_res[i] < num_xcp;
 		xcp_cfg->xcp_res[i].num_inst =
 			res_lt_xcp ? 1 : max_res[i] / num_xcp;
 		xcp_cfg->xcp_res[i].num_inst =
Signature · 1 line
2.46.0
Reviewed-by Reviewed-by Lijo Lazar on v2 1/1
#1 lore raw

AMD General

Regards,
Hawking
-----Original Message-----
From: Kamal, Asad <[email protected]>
Sent: Thursday, June 18, 2026 1:12 PM
To: [email protected]
Cc: Lazar, Lijo <[email protected]>; Zhang, Hawking <[email protected]>; Ma, Le <[email protected]>; Zhang, Morris <[email protected]>; Deucher, Alexander <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Kamal, Asad <[email protected]>
Subject: [PATCH v2] drm/amdgpu: validate XCP topology counts before division

In aqua_vanjaram_get_xcp_res_info(), max_res[i] can be zero.
When res_lt_xcp is true the code divides num_xcp by max_res[i], causing a divide fault.

Skip the loop body for absent resources.

v2: Remove redundant checks (Lijo)

---
 drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c +3 -1
index 72ea37dbfea8..1c11cc280599 100644
@@ -273,8 +273,10 @@ static int aqua_vanjaram_get_xcp_res_info(struct amdgpu_xcp_mgr *xcp_mgr,
        xcp_cfg->num_res = ARRAY_SIZE(max_res);
 
        for (i = 0; i < xcp_cfg->num_res; i++) {
-               res_lt_xcp = max_res[i] < num_xcp;
                xcp_cfg->xcp_res[i].id = i;
+               if (!max_res[i])
+                       continue;
+               res_lt_xcp = max_res[i] < num_xcp;
                xcp_cfg->xcp_res[i].num_inst =
                        res_lt_xcp ? 1 : max_res[i] / num_xcp;
                xcp_cfg->xcp_res[i].num_inst =

--
2.46.0