Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1522651

[PATCH] drm/amd/powerplay: check if table_info is NULL before dereferencing it

From Colin King <colin.king@canonical.com>
Newsgroups linux.kernel
Subject [PATCH] drm/amd/powerplay: check if table_info is NULL before dereferencing it
Date 2016-11-15 14:00 +0100
Message-ID <sDLvb-52P-13@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


From: Colin Ian King <colin.king@canonical.com>

table_info is being dereferenced before a null check, which implies
a potential null pointer deference error.  Fix this by moving the null
check of table_info to the start of smu7_get_evv_voltages to avoid
potential null pointer deferencing.

Found with static analysis by CoverityScan, CID 1377752

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
index 28e748d..6798067 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
@@ -1473,6 +1473,8 @@ static int smu7_get_evv_voltages(struct pp_hwmgr *hwmgr)
 			(struct phm_ppt_v1_information *)hwmgr->pptable;
 	struct phm_ppt_v1_clock_voltage_dependency_table *sclk_table = NULL;
 
+	if (table_info == NULL)
+		return -EINVAL;
 
 	for (i = 0; i < SMU7_MAX_LEAKAGE_COUNT; i++) {
 		vv_id = ATOM_VIRTUAL_VOLTAGE_ID0 + i;
@@ -1483,8 +1485,6 @@ static int smu7_get_evv_voltages(struct pp_hwmgr *hwmgr)
 						table_info->vddgfx_lookup_table, vv_id, &sclk)) {
 				if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
 							PHM_PlatformCaps_ClockStretcher)) {
-					if (table_info == NULL)
-						return -EINVAL;
 					sclk_table = table_info->vdd_dep_on_sclk;
 
 					for (j = 1; j < sclk_table->count; j++) {
@@ -1517,8 +1517,6 @@ static int smu7_get_evv_voltages(struct pp_hwmgr *hwmgr)
 					table_info->vddc_lookup_table, vv_id, &sclk)) {
 				if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
 						PHM_PlatformCaps_ClockStretcher)) {
-					if (table_info == NULL)
-						return -EINVAL;
 					sclk_table = table_info->vdd_dep_on_sclk;
 
 					for (j = 1; j < sclk_table->count; j++) {
-- 
2.10.2

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] drm/amd/powerplay: check if table_info is NULL before dereferencing it Colin King <colin.king@canonical.com> - 2016-11-15 14:00 +0100
  Re: [PATCH] drm/amd/powerplay: check if table_info is NULL before  dereferencing it Colin Ian King <colin.king@canonical.com> - 2016-11-15 17:10 +0100
    RE: [PATCH] drm/amd/powerplay: check if table_info is NULL before  dereferencing it "Deucher, Alexander" <Alexander.Deucher@amd.com> - 2016-11-15 17:20 +0100
  RE: [PATCH] drm/amd/powerplay: check if table_info is NULL before  dereferencing it "Deucher, Alexander" <Alexander.Deucher@amd.com> - 2016-11-15 17:10 +0100

csiph-web