drm/amdgpu: fix null ptr access
Subsystems (3)
PATCH 1/1 drm/amdgpu: fix null ptr access
check null ptr first before access its element
--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 2 +- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1 -1
@@ -463,7 +463,7 @@ int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_versioconst struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;int r =0 ; -if (!pp_funcs->load_firmware) +if (!pp_funcs || !pp_funcs->load_firmware)return 0 ;mutex_lock (&adev->pm.mutex);
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1 -1
@@ -3281,7 +3281,7 @@ void amdgpu_smu_stb_debug_fs_init(struct amdgpu_device *adev)struct smu_context *smu = adev->powerplay.pp_handle; -if (!smu->stb_context.stb_buf_size) +if (!smu || !smu->stb_context.stb_buf_size)return ; debugfs_create_file_size("amdgpu_smu_stb_dump",
Signature · 1 line
2.25.1
[AMD Official Use Only]
Quoted 22 lines
-----Original Message-----
From: Cui, Flora <[email protected]>
Sent: Thursday, January 13, 2022 2:58 PM
To: [email protected]; Quan, Evan <[email protected]>
Cc: Cui, Flora <[email protected]>
Subject: [PATCH] drm/amdgpu: fix null ptr accesscheck null ptr first before access its element
Signed-off-by Flora Cui <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 2 +- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -463,7 +463,7 @@ int amdgpu_pm_load_smu_firmware(struct
amdgpu_device*adev,uint32_t*smu_versio
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_versio · line 467
Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-1const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;int r =0 ; -if (!pp_funcs->load_firmware) +if (!pp_funcs || !pp_funcs->load_firmware)return 0 ;
[Quan, Evan] This seems fine to me.
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0mutex_lock (&adev->pm.mutex);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c void amdgpu_smu_stb_debug_fs_init(struct · line 3286
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1@@ -3281,7 +3281,7 @@ void amdgpu_smu_stb_debug_fs_init(struct amdgpu_device *adev)struct smu_context *smu = adev->powerplay.pp_handle; -if (!smu->stb_context.stb_buf_size) +if (!smu || !smu->stb_context.stb_buf_size)return ;
[Quan, Evan] For this one, maybe as Lijo suggested, a check for "!adev->pm.dpm_enabled" in amdgpu_debugfs_pm_init() is better.
BR
Evan
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1debugfs_create_file_size("amdgpu_smu_stb_dump", --2.25.1