drm/amd/display: dc_get_vmid_use_vector() crashes when get called
authorPeikang Zhang <peikang.zhang@amd.com>
Mon, 20 Jan 2020 14:25:15 +0000 (09:25 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 6 Feb 2020 20:04:37 +0000 (15:04 -0500)
[Why]
int i can go out of boundary which will cause crash

[How]
Fixed the maximum value of i to avoid i going out of boundary

Signed-off-by: Peikang Zhang <peikang.zhang@amd.com>
Reviewed-by: Jun Lei <Jun.Lei@amd.com>
Acked-by: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc_vm_helper.c

index a96d8de..f2b39ec 100644 (file)
@@ -62,7 +62,7 @@ int dc_get_vmid_use_vector(struct dc *dc)
        int i;
        int in_use = 0;
 
-       for (i = 0; i < dc->vm_helper->num_vmid; i++)
+       for (i = 0; i < MAX_HUBP; i++)
                in_use |= dc->vm_helper->hubp_vmid_usage[i].vmid_usage[0]
                        | dc->vm_helper->hubp_vmid_usage[i].vmid_usage[1];
        return in_use;