drm/amd/pm: fix error handling
Subsystems (3)
PATCH 1/1 drm/amd/pm: fix error handling
From: Tom Rix <[email protected]>
clang static analysis reports this error amdgpu_smu.c:2289:9: warning: Called function pointer
is null (null dereference)
return smu->ppt_funcs->emit_clk_levels(
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~There is a logic error in the earlier check ofemit_clk_levels. The error value is set to
the ret variable but ret is never used. Return
directly and remove the unneeded ret variable.
--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1 -2
@@ -2274,7 +2274,6 @@ static int smu_emit_ppclk_levels(void *handle, enum pp_clock_type type, char *bu {struct smu_context *smu = handle;enum smu_clk_type clk_type; -int ret =0 ; clk_type =smu_convert_to_smuclk (type);if (clk_type ==SMU_CLK_COUNT )
@@ -2284,7 +2283,7 @@ static int smu_emit_ppclk_levels(void *handle, enum pp_clock_type type, char *bureturn -EOPNOTSUPP ;if (!smu->ppt_funcs->emit_clk_levels) - ret = -ENOENT ; +return -ENOENT ;return smu->ppt_funcs->emit_clk_levels (smu, clk_type, buf, offset);
Signature · 1 line
2.26.3
[AMD Official Use Only]
Quoted 60 lines
-----Original Message-----
From: [email protected] <[email protected]>
Sent: Saturday, February 5, 2022 11:00 PM
To: Quan, Evan <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Lazar, Lijo <[email protected]>; Powell, Darren <[email protected]>; Chen, Guchun <[email protected]>; Grodzovsky, Andrey <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; Tom Rix <[email protected]>
Subject: [PATCH] drm/amd/pm: fix error handlingFrom: Tom Rix <[email protected]>
clang static analysis reports this error amdgpu_smu.c:2289:9: warning: Called function pointer
is null (null dereference)return smu->ppt_funcs->emit_clk_levels( ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~There is a logic error in the earlier check of
emit_clk_levels. The error value is set to
the ret variable but ret is never used. Return
directly and remove the unneeded ret variable.Fixes 5d64f9bbb628 ("amdgpu/pm: Implement new API function "emit" thataccepts buffer base and write offset")
Signed-off-by Tom Rix <[email protected]>--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0@@ -2274,7 +2274,6 @@ static int smu_emit_ppclk_levels(void *handle,enum
pp_clock_typetype, char *bu
{drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1struct smu_context *smu = handle;enum smu_clk_type clk_type; -int ret =0 ; clk_type =smu_convert_to_smuclk (type);if (clk_type ==SMU_CLK_COUNT )@@ -2284,7 +2283,7 @@ static int smu_emit_ppclk_levels(void *handle,enum
pp_clock_typetype, char *budrivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-2return -EOPNOTSUPP ;if (!smu->ppt_funcs->emit_clk_levels) - ret = -ENOENT ; +return -ENOENT ;return smu->ppt_funcs->emit_clk_levels (smu, clk_type, buf, offset); --2.26.3
Alex Deucher
AppliedApplied. Thanks!
Alex
Quoted 65 lines · Evan
[AMD Official Use Only]
Reviewed-by Evan Quan <[email protected]>Quoted 60 lines
-----Original Message-----
From: [email protected] <[email protected]>
Sent: Saturday, February 5, 2022 11:00 PM
To: Quan, Evan <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Lazar, Lijo <[email protected]>; Powell, Darren <[email protected]>; Chen, Guchun <[email protected]>; Grodzovsky, Andrey <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; Tom Rix <[email protected]>
Subject: [PATCH] drm/amd/pm: fix error handlingFrom: Tom Rix <[email protected]>
clang static analysis reports this error amdgpu_smu.c:2289:9: warning: Called function pointer
is null (null dereference)return smu->ppt_funcs->emit_clk_levels( ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~There is a logic error in the earlier check of
emit_clk_levels. The error value is set to
the ret variable but ret is never used. Return
directly and remove the unneeded ret variable.Fixes 5d64f9bbb628 ("amdgpu/pm: Implement new API function "emit" thataccepts buffer base and write offset")
Signed-off-by Tom Rix <[email protected]>--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0@@ -2274,7 +2274,6 @@ static int smu_emit_ppclk_levels(void *handle,enum
pp_clock_typetype, char *bu{ struct smu_context *smu = handle; enum smu_clk_type clk_type;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1-int ret =0 ; clk_type =smu_convert_to_smuclk (type);if (clk_type ==SMU_CLK_COUNT )@@ -2284,7 +2283,7 @@ static int smu_emit_ppclk_levels(void *handle,enum
pp_clock_typetype, char *bureturn -EOPNOTSUPP; if (!smu->ppt_funcs->emit_clk_levels)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-2- ret = -ENOENT ; +return -ENOENT ;return smu->ppt_funcs->emit_clk_levels (smu, clk_type, buf, offset); --2.26.3