All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] drm/amdgpu: fix null ptr access
@ 2022-01-14  2:54 Flora Cui
  2022-01-14  3:10 ` Quan, Evan
  0 siblings, 1 reply; 2+ messages in thread
From: Flora Cui @ 2022-01-14  2:54 UTC (permalink / raw)
  To: Evan.Quan, amd-gfx; +Cc: Flora Cui

check null ptr first before access its element

v2: check adev->pm.dpm_enabled early in amdgpu_debugfs_pm_init()

Signed-off-by: Flora Cui <flora.cui@amd.com>
---
 drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 2 +-
 drivers/gpu/drm/amd/pm/amdgpu_pm.c  | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

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;
 
 	mutex_lock(&adev->pm.mutex);
diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
index 1b03ad7a21ad..49a9c6375343 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
@@ -3583,6 +3583,9 @@ void amdgpu_debugfs_pm_init(struct amdgpu_device *adev)
 	struct drm_minor *minor = adev_to_drm(adev)->primary;
 	struct dentry *root = minor->debugfs_root;
 
+	if (!adev->pm.dpm_enabled)
+		return;
+
 	debugfs_create_file("amdgpu_pm_info", 0444, root, adev,
 			    &amdgpu_debugfs_pm_info_fops);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH v2] drm/amdgpu: fix null ptr access
  2022-01-14  2:54 [PATCH v2] drm/amdgpu: fix null ptr access Flora Cui
@ 2022-01-14  3:10 ` Quan, Evan
  0 siblings, 0 replies; 2+ messages in thread
From: Quan, Evan @ 2022-01-14  3:10 UTC (permalink / raw)
  To: Cui, Flora, amd-gfx

[AMD Official Use Only]

For the patch with power code change, we usually have the patch title prefixed with "drm/amd/pm".  
With that fixed, the patch is reviewed-by: Evan Quan <evan.quan@amd.com>

> -----Original Message-----
> From: Cui, Flora <Flora.Cui@amd.com>
> Sent: Friday, January 14, 2022 10:54 AM
> To: Quan, Evan <Evan.Quan@amd.com>; amd-gfx@lists.freedesktop.org
> Cc: Cui, Flora <Flora.Cui@amd.com>
> Subject: [PATCH v2] drm/amdgpu: fix null ptr access
> 
> check null ptr first before access its element
> 
> v2: check adev->pm.dpm_enabled early in amdgpu_debugfs_pm_init()
> 
> Signed-off-by: Flora Cui <flora.cui@amd.com>
> ---
>  drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 2 +-
> drivers/gpu/drm/amd/pm/amdgpu_pm.c  | 3 +++
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> 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;
> 
>  	mutex_lock(&adev->pm.mutex);
> diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> index 1b03ad7a21ad..49a9c6375343 100644
> --- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> +++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> @@ -3583,6 +3583,9 @@ void amdgpu_debugfs_pm_init(struct
> amdgpu_device *adev)
>  	struct drm_minor *minor = adev_to_drm(adev)->primary;
>  	struct dentry *root = minor->debugfs_root;
> 
> +	if (!adev->pm.dpm_enabled)
> +		return;
> +
>  	debugfs_create_file("amdgpu_pm_info", 0444, root, adev,
>  			    &amdgpu_debugfs_pm_info_fops);
> 
> --
> 2.25.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-14  3:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-14  2:54 [PATCH v2] drm/amdgpu: fix null ptr access Flora Cui
2022-01-14  3:10 ` Quan, Evan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.