aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/files/0294-drm-amd-powerplay-add-powerplay-valid-check-to-avoid.patch
blob: 1a2b8ff9ba96ff6c721c71f9048c85363ba2b516 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
From 4b7da07fec96efab2edfc92f54af4ee9ef443a3b Mon Sep 17 00:00:00 2001
From: Rex Zhu <Rex.Zhu@amd.com>
Date: Tue, 29 Dec 2015 13:56:03 +0800
Subject: [PATCH 0294/1110] drm/amd/powerplay: add powerplay valid check to
 avoid null point.

In case CONFIG_DRM_AMD_POWERPLAY is defined and amdgpu.powerplay=0.
some functions in powrplay can also be called by DAL. and the input parameter is *adev.
if just check point not NULL was not enough and will lead to NULL point error.

Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
index 86e86e2..351ebf2 100644
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
@@ -789,7 +789,9 @@ int amd_powerplay_get_current_clocks(void *handle,
 	struct amd_pp_simple_clock_info simple_clocks;
 	struct pp_clock_info hw_clocks;
 
-	if (handle == NULL || clocks == NULL)
+	PP_CHECK((struct pp_instance *)handle);
+
+	if (clocks == NULL)
 		return -EINVAL;
 
 	hwmgr = ((struct pp_instance *)handle)->hwmgr;
@@ -831,7 +833,9 @@ int amd_powerplay_get_clock_by_type(void *handle, enum amd_pp_clock_type type, s
 
 	struct pp_hwmgr *hwmgr;
 
-	if (handle == NULL || clocks == NULL)
+	PP_CHECK((struct pp_instance *)handle);
+
+	if (clocks == NULL)
 		return -EINVAL;
 
 	hwmgr = ((struct pp_instance *)handle)->hwmgr;
@@ -847,7 +851,9 @@ int amd_powerplay_get_display_mode_validation_clocks(void *handle,
 	int result = -1;
 	struct pp_hwmgr  *hwmgr;
 
-	if (handle == NULL || clocks == NULL)
+	PP_CHECK((struct pp_instance *)handle);
+
+	if (clocks == NULL)
 		return -EINVAL;
 
 	hwmgr = ((struct pp_instance *)handle)->hwmgr;
-- 
2.7.4