[PATCH] drm/amdgpu: fix null ptr access
Quan, Evan
Evan.Quan at amd.com
Fri Jan 14 01:19:44 UTC 2022
[AMD Official Use Only]
> -----Original Message-----
> From: Cui, Flora <Flora.Cui at amd.com>
> Sent: Thursday, January 13, 2022 2:58 PM
> To: amd-gfx at lists.freedesktop.org; Quan, Evan <Evan.Quan at amd.com>
> Cc: Cui, Flora <Flora.Cui at amd.com>
> Subject: [PATCH] drm/amdgpu: fix null ptr access
>
> check null ptr first before access its element
>
> Signed-off-by: Flora Cui <flora.cui at amd.com>
> ---
> 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(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
> b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
> index f0daa66f5b3d..5fc33893a68c 100644
> --- a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
> +++ b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
> @@ -463,7 +463,7 @@ int amdgpu_pm_load_smu_firmware(struct
> amdgpu_device *adev, uint32_t *smu_versio
> const 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.
>
> mutex_lock(&adev->pm.mutex);
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> index 828cb932f6a9..aa640a9c6137 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> @@ -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
>
> debugfs_create_file_size("amdgpu_smu_stb_dump",
> --
> 2.25.1
More information about the amd-gfx
mailing list