Skip to content

Commit

Permalink
drm/amd/pp: Fix potential NULL pointer dereference in atomctrl_initia…
Browse files Browse the repository at this point in the history
…lize_mc_reg_table

The function atomctrl_initialize_mc_reg_table() and
atomctrl_initialize_mc_reg_table_v2_2() does not check the return
value of smu_atom_get_data_table(). If smu_atom_get_data_table()
fails to retrieve vram_info, it returns NULL which is later
dereferenced.

Fixes: b3892e2 ("drm/amd/pp: Use atombios api directly in powerplay (v2)")
Fixes: 5f92b48 ("drm/amd/pm: add mc register table initialization")
Signed-off-by: Charles Han <hanchunchao@inspur.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
  • Loading branch information
Charles Han authored and Alex Deucher committed Apr 7, 2025
1 parent d69248c commit 820116a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ int atomctrl_initialize_mc_reg_table(
vram_info = (ATOM_VRAM_INFO_HEADER_V2_1 *)
smu_atom_get_data_table(hwmgr->adev,
GetIndexIntoMasterTable(DATA, VRAM_Info), &size, &frev, &crev);
if (!vram_info) {
pr_err("Could not retrieve the VramInfo table!");
return -EINVAL;
}

if (module_index >= vram_info->ucNumOfVRAMModule) {
pr_err("Invalid VramInfo table.");
Expand Down Expand Up @@ -180,6 +184,10 @@ int atomctrl_initialize_mc_reg_table_v2_2(
vram_info = (ATOM_VRAM_INFO_HEADER_V2_2 *)
smu_atom_get_data_table(hwmgr->adev,
GetIndexIntoMasterTable(DATA, VRAM_Info), &size, &frev, &crev);
if (!vram_info) {
pr_err("Could not retrieve the VramInfo table!");
return -EINVAL;
}

if (module_index >= vram_info->ucNumOfVRAMModule) {
pr_err("Invalid VramInfo table.");
Expand Down

0 comments on commit 820116a

Please sign in to comment.