]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
drm/amd: check num of link levels when update pcie param
authorLin.Cao <lincao12@amd.com>
Wed, 25 Oct 2023 03:32:41 +0000 (11:32 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 26 Oct 2023 23:04:19 +0000 (19:04 -0400)
In SR-IOV environment, the value of pcie_table->num_of_link_levels will
be 0, and num_of_levels - 1 will cause array index out of bounds

Signed-off-by: Lin.Cao <lincao12@amd.com>
Acked-by: Jingwen Chen <Jingwen.Chen2@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c

index 3917ae5e681a3088f959d1f2ad2daefd02e896f1..a49e5adf7cc3d7f2c7ed045a7cfc6947318a39d0 100644 (file)
@@ -2438,6 +2438,9 @@ int smu_v13_0_update_pcie_parameters(struct smu_context *smu,
        uint32_t smu_pcie_arg;
        int ret, i;
 
+       if (!num_of_levels)
+               return 0;
+
        if (!(smu->adev->pm.pp_feature & PP_PCIE_DPM_MASK)) {
                if (pcie_table->pcie_gen[num_of_levels - 1] < pcie_gen_cap)
                        pcie_gen_cap = pcie_table->pcie_gen[num_of_levels - 1];