[PATCH] cpufreq/amd-pstate-ut: Fix an "Uninitialized variables" issue

Qianqiang Liu posted 1 patch 2 months, 2 weeks ago
drivers/cpufreq/amd-pstate-ut.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] cpufreq/amd-pstate-ut: Fix an "Uninitialized variables" issue
Posted by Qianqiang Liu 2 months, 2 weeks ago
Using uninitialized value "mode2" when calling "amd_pstate_get_mode_string".
Set "mode2" to "AMD_PSTATE_DISABLE" by default.

Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>
---
 drivers/cpufreq/amd-pstate-ut.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/amd-pstate-ut.c b/drivers/cpufreq/amd-pstate-ut.c
index c291b3dbec38..f66701514d90 100644
--- a/drivers/cpufreq/amd-pstate-ut.c
+++ b/drivers/cpufreq/amd-pstate-ut.c
@@ -270,7 +270,7 @@ static int amd_pstate_set_mode(enum amd_pstate_mode mode)
 
 static void amd_pstate_ut_check_driver(u32 index)
 {
-	enum amd_pstate_mode mode1, mode2;
+	enum amd_pstate_mode mode1, mode2 = AMD_PSTATE_DISABLE;
 	int ret;
 
 	for (mode1 = AMD_PSTATE_DISABLE; mode1 < AMD_PSTATE_MAX; mode1++) {
-- 
2.39.2
Re: [PATCH] cpufreq/amd-pstate-ut: Fix an "Uninitialized variables" issue
Posted by Mario Limonciello 2 months, 2 weeks ago
On 9/10/2024 18:39, Qianqiang Liu wrote:
> Using uninitialized value "mode2" when calling "amd_pstate_get_mode_string".
> Set "mode2" to "AMD_PSTATE_DISABLE" by default.
> 
> Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>
> ---
>   drivers/cpufreq/amd-pstate-ut.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate-ut.c b/drivers/cpufreq/amd-pstate-ut.c
> index c291b3dbec38..f66701514d90 100644
> --- a/drivers/cpufreq/amd-pstate-ut.c
> +++ b/drivers/cpufreq/amd-pstate-ut.c
> @@ -270,7 +270,7 @@ static int amd_pstate_set_mode(enum amd_pstate_mode mode)
>   
>   static void amd_pstate_ut_check_driver(u32 index)
>   {
> -	enum amd_pstate_mode mode1, mode2;
> +	enum amd_pstate_mode mode1, mode2 = AMD_PSTATE_DISABLE;
>   	int ret;
>   
>   	for (mode1 = AMD_PSTATE_DISABLE; mode1 < AMD_PSTATE_MAX; mode1++) {

Acked-by: Mario Limonciello <mario.limonciello@amd.com>

Much appreciated.  I needed to redo the PR for 6.12 and I added this as 
well.