Skip to contentSkip to conversation

drm/amdgpu: fix null ptr access

PATCH In review Flora Cui 2 participants 2 messages Jan 14, 2022

Subsystems (3)
lore
Share & tools
lore

Flora Cui

author
#0 lore raw

PATCH v2 1/1 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()

---
 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(-)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1 -1
index f0daa66f5b3d..5fc33893a68c 100644
@@ -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);
drivers/gpu/drm/amd/pm/amdgpu_pm.c +3 -0
index 1b03ad7a21ad..49a9c6375343 100644
@@ -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);
 
Signature · 1 line
2.25.1
#1 lore raw

[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 <[email protected]>

Quoted 50 lines

-----Original Message-----
From: Cui, Flora <[email protected]>
Sent: Friday, January 14, 2022 10:54 AM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Cui, Flora <[email protected]>
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()

---
 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(-)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0 -0
index f0daa66f5b3d..5fc33893a68c 100644
@@ -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 +1 -1
 	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);
drivers/gpu/drm/amd/pm/amdgpu_pm.c +3 -1
index 1b03ad7a21ad..49a9c6375343 100644
@@ -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