]> git.hungrycats.org Git - linux/commitdiff
drm/amdgpu: validate XCP topology counts before division
authorAsad Kamal <asad.kamal@amd.com>
Tue, 16 Jun 2026 13:24:05 +0000 (21:24 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 1 Jul 2026 15:08:46 +0000 (11:08 -0400)
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)

Signed-off-by: Asad Kamal <asad.kamal@amd.com>
Reviewed-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/aqua_vanjaram.c

index 72ea37dbfea8d86ed2f42bdd4af15174f988f397..1c11cc2805992a2a6b5746b8afbfe5812c8529d2 100644 (file)
@@ -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 =