drm/amd/pm: fix error handling
authorTom Rix <trix@redhat.com>
Sat, 5 Feb 2022 15:00:08 +0000 (07:00 -0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 7 Feb 2022 23:03:50 +0000 (18:03 -0500)
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" that accepts buffer base and write offset")
Reviewed-by: Evan Quan <evan.quan@amd.com>
Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c

index 7925edc..e846231 100644 (file)
@@ -2279,7 +2279,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)
@@ -2289,7 +2288,7 @@ static int smu_emit_ppclk_levels(void *handle, enum pp_clock_type type, char *bu
                return -EOPNOTSUPP;
 
        if (!smu->ppt_funcs->emit_clk_levels)
-               ret = -ENOENT;
+               return -ENOENT;
 
        return smu->ppt_funcs->emit_clk_levels(smu, clk_type, buf, offset);