Skip to contentSkip to conversation

drm/amd/powerplay: avoid null pointer

PATCH In review Yintian Tao 2 participants 2 messages Dec 9, 2019 – Dec 10, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/powerplay: avoid null pointer

because some asics have no smu.ppt_funcs
we need add one check for it otherwise
it will raise null pointer problem.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2 -1
index a21ee035ca57..b8a42ebb2f5a 100644
@@ -160,7 +160,8 @@ static ssize_t amdgpu_get_dpm_state(struct device *dev,
 	enum amd_pm_state_type pm;
 
 	if (is_support_sw_smu(adev)) {
-		if (adev->smu.ppt_funcs->get_current_power_state)
+		if (adev->smu.ppt_funcs &&
+		    adev->smu.ppt_funcs->get_current_power_state)
 			pm = smu_get_current_power_state(&adev->smu);
 		else
 			pm = adev->pm.dpm.user_state;
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#1 lore raw

Thanks. Reviewed-by: Evan Quan <[email protected]>

Quoted 36 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Yintian Tao
Sent: Tuesday, December 10, 2019 1:27 AM
To: Deucher, Alexander <[email protected]>; Feng, Kenneth <[email protected]>
Cc: [email protected]; Tao, Yintian <[email protected]>
Subject: [PATCH] drm/amd/powerplay: avoid null pointer

because some asics have no smu.ppt_funcs we need add one check for it otherwise it will raise null pointer problem.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2 -1
index a21ee035ca57..b8a42ebb2f5a 100644
@@ -160,7 +160,8 @@ static ssize_t amdgpu_get_dpm_state(struct device
 *dev,
 	enum amd_pm_state_type pm;
 
 	if (is_support_sw_smu(adev)) {
-		if (adev->smu.ppt_funcs->get_current_power_state)
+		if (adev->smu.ppt_funcs &&
+		    adev->smu.ppt_funcs->get_current_power_state)
 			pm = smu_get_current_power_state(&adev->smu);
 		else

pm = adev->pm.dpm.user_state;
--
2.17.1

Quoted 9 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.free
desktop.org%2Fmailman%2Flistinfo%2Famd- gfx&amp;data=02%7C01%7Cevan.quan%40amd.com%7Cc3d9c9c42b8648b0c2 d708d77cccf3f3%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C6371 15092081521686&amp;sdata=qDCT%2BPXFgCAu9GDTRpNjW890IVBEXuWMHx dN9OZZIsE%3D&amp;reserved=0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx