Skip to contentSkip to conversation

drm/amdgpu/pm: Check the return value of smum_send_msg_to_smc

PATCH In review Ma Jun 2 participants 2 messages Apr 26, 2024 – Apr 28, 2024

Subsystems (3)
lore
Share & tools
lore

Ma Jun

author
#0 lore raw

PATCH 1/1 drm/amdgpu/pm: Check the return value of smum_send_msg_to_smc

Check the return value of smum_send_msg_to_smc, otherwise we might use an uninitialized variable "now"

---
 drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c +6 -2
index 02ba68d7c654..0b181bc8931c 100644
@@ -1036,7 +1036,9 @@ static int smu10_print_clock_levels(struct pp_hwmgr *hwmgr,
 
 	switch (type) {
 	case PP_SCLK:
-		smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetGfxclkFrequency, &now);
+		ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetGfxclkFrequency, &now);
+		if (ret)
+			return ret;
 
 	/* driver only know min/max gfx_clk, Add level 1 for all other gfx clks */
 		if (now == data->gfx_max_freq_limit/100)
@@ -1057,7 +1059,9 @@ static int smu10_print_clock_levels(struct pp_hwmgr *hwmgr,
 					i == 2 ? "*" : "");
 		break;
 	case PP_MCLK:
-		smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetFclkFrequency, &now);
+		ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetFclkFrequency, &now);
+		if (ret)
+			return ret;
 
 		for (i = 0; i < mclk_table->count; i++)
 			size += sprintf(buf + size, "%d: %uMhz %s\n",
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw

[Public]

This patch is,

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Ma Jun
Sent: Friday, April 26, 2024 5:37 PM
To: [email protected]; Koenig, Christian <[email protected]>; Deucher, Alexander <[email protected]>
Cc: Ma, Jun <[email protected]>
Subject: [PATCH] drm/amdgpu/pm: Check the return value of smum_send_msg_to_smc

Check the return value of smum_send_msg_to_smc, otherwise we might use an uninitialized variable "now"

---
 drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c +3 -1
index 02ba68d7c654..0b181bc8931c 100644
@@ -1036,7 +1036,9 @@ static int smu10_print_clock_levels(struct pp_hwmgr *hwmgr,
 
        switch (type) {
        case PP_SCLK:
-               smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetGfxclkFrequency, &now);
+               ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetGfxclkFrequency, &now);
+               if (ret)
+                       return ret;
 
        /* driver only know min/max gfx_clk, Add level 1 for all other gfx clks */
                if (now == data->gfx_max_freq_limit/100) @@ -1057,7 +1059,9 @@ static int smu10_print_clock_levels(struct pp_hwmgr *hwmgr,
                                        i == 2 ? "*" : "");
                break;
        case PP_MCLK:
-               smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetFclkFrequency, &now);
+               ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetFclkFrequency, &now);
+               if (ret)

+ return ret;

                for (i = 0; i < mclk_table->count; i++)
                        size += sprintf(buf + size, "%d: %uMhz %s\n",

--
2.34.1