mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
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) 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>
This commit is contained in:
parent
b68f165492
commit
0eda57ee30
|
|
@ -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 =
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user