]> git.baikalelectronics.ru Git - kernel.git/commitdiff
amdgpu/pm: prevent array underflow in vega20_odn_edit_dpm_table()
authorDan Carpenter <error27@gmail.com>
Tue, 15 Nov 2022 12:56:57 +0000 (15:56 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:41:03 +0000 (11:41 +0100)
[ Upstream commit d27252b5706e51188aed7647126e44dcf9e940c1 ]

In the PP_OD_EDIT_VDDC_CURVE case the "input_index" variable is capped at
2 but not checked for negative values so it results in an out of bounds
read.  This value comes from the user via sysfs.

Fixes: bf0955fadd51 ("drm/amd/powerplay: added vega20 overdrive support V3")
Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c

index 947e4fa3c5e68dcbe9fdd2df8a00f209c9deb55b..d499add3601ab9b037a40f66d9961b92e6d5c75b 100644 (file)
@@ -2894,7 +2894,8 @@ static int vega20_odn_edit_dpm_table(struct pp_hwmgr *hwmgr,
                        data->od8_settings.od8_settings_array;
        OverDriveTable_t *od_table =
                        &(data->smc_state_table.overdrive_table);
-       int32_t input_index, input_clk, input_vol, i;
+       int32_t input_clk, input_vol, i;
+       uint32_t input_index;
        int od8_id;
        int ret;