]> www.infradead.org Git - linux.git/commitdiff
drm/amdgpu: fix unchecked return value warning for amdgpu_atombios
authorTim Huang <tim.huang@amd.com>
Thu, 1 Aug 2024 05:47:55 +0000 (13:47 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 6 Aug 2024 15:11:03 +0000 (11:11 -0400)
This resolves the unchecded return value warning reported by Coverity.

Signed-off-by: Tim Huang <tim.huang@amd.com>
Reviewed-by: Jesse Zhang <jesse.zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c

index 7dc102f0bc1d3cbf47e86fd1e8fd791101e6955b..0c8975ac5af9ed294b525c3e3071bd4ed4b2e9c0 100644 (file)
@@ -1018,8 +1018,9 @@ int amdgpu_atombios_get_clock_dividers(struct amdgpu_device *adev,
                if (clock_type == COMPUTE_ENGINE_PLL_PARAM) {
                        args.v3.ulClockParams = cpu_to_le32((clock_type << 24) | clock);
 
-                       amdgpu_atom_execute_table(adev->mode_info.atom_context, index, (uint32_t *)&args,
-                               sizeof(args));
+                       if (amdgpu_atom_execute_table(adev->mode_info.atom_context,
+                           index, (uint32_t *)&args, sizeof(args)))
+                               return -EINVAL;
 
                        dividers->post_div = args.v3.ucPostDiv;
                        dividers->enable_post_div = (args.v3.ucCntlFlag &
@@ -1039,8 +1040,9 @@ int amdgpu_atombios_get_clock_dividers(struct amdgpu_device *adev,
                        if (strobe_mode)
                                args.v5.ucInputFlag = ATOM_PLL_INPUT_FLAG_PLL_STROBE_MODE_EN;
 
-                       amdgpu_atom_execute_table(adev->mode_info.atom_context, index, (uint32_t *)&args,
-                               sizeof(args));
+                       if (amdgpu_atom_execute_table(adev->mode_info.atom_context,
+                           index, (uint32_t *)&args, sizeof(args)))
+                               return -EINVAL;
 
                        dividers->post_div = args.v5.ucPostDiv;
                        dividers->enable_post_div = (args.v5.ucCntlFlag &
@@ -1058,8 +1060,9 @@ int amdgpu_atombios_get_clock_dividers(struct amdgpu_device *adev,
                /* fusion */
                args.v4.ulClock = cpu_to_le32(clock);   /* 10 khz */
 
-               amdgpu_atom_execute_table(adev->mode_info.atom_context, index, (uint32_t *)&args,
-                       sizeof(args));
+               if (amdgpu_atom_execute_table(adev->mode_info.atom_context,
+                   index, (uint32_t *)&args, sizeof(args)))
+                       return -EINVAL;
 
                dividers->post_divider = dividers->post_div = args.v4.ucPostDiv;
                dividers->real_clock = le32_to_cpu(args.v4.ulClock);
@@ -1070,8 +1073,9 @@ int amdgpu_atombios_get_clock_dividers(struct amdgpu_device *adev,
                args.v6_in.ulClock.ulComputeClockFlag = clock_type;
                args.v6_in.ulClock.ulClockFreq = cpu_to_le32(clock);    /* 10 khz */
 
-               amdgpu_atom_execute_table(adev->mode_info.atom_context, index, (uint32_t *)&args,
-                       sizeof(args));
+               if (amdgpu_atom_execute_table(adev->mode_info.atom_context,
+                   index, (uint32_t *)&args, sizeof(args)))
+                       return -EINVAL;
 
                dividers->whole_fb_div = le16_to_cpu(args.v6_out.ulFbDiv.usFbDiv);
                dividers->frac_fb_div = le16_to_cpu(args.v6_out.ulFbDiv.usFbDivFrac);
@@ -1113,8 +1117,9 @@ int amdgpu_atombios_get_memory_pll_dividers(struct amdgpu_device *adev,
                        if (strobe_mode)
                                args.ucInputFlag |= MPLL_INPUT_FLAG_STROBE_MODE_EN;
 
-                       amdgpu_atom_execute_table(adev->mode_info.atom_context, index, (uint32_t *)&args,
-                               sizeof(args));
+                       if (amdgpu_atom_execute_table(adev->mode_info.atom_context,
+                           index, (uint32_t *)&args, sizeof(args)))
+                               return -EINVAL;
 
                        mpll_param->clkfrac = le16_to_cpu(args.ulFbDiv.usFbDivFrac);
                        mpll_param->clkf = le16_to_cpu(args.ulFbDiv.usFbDiv);
@@ -1211,8 +1216,9 @@ int amdgpu_atombios_get_max_vddc(struct amdgpu_device *adev, u8 voltage_type,
                args.v2.ucVoltageMode = 0;
                args.v2.usVoltageLevel = 0;
 
-               amdgpu_atom_execute_table(adev->mode_info.atom_context, index, (uint32_t *)&args,
-                       sizeof(args));
+               if (amdgpu_atom_execute_table(adev->mode_info.atom_context,
+                   index, (uint32_t *)&args, sizeof(args)))
+                       return -EINVAL;
 
                *voltage = le16_to_cpu(args.v2.usVoltageLevel);
                break;
@@ -1221,8 +1227,9 @@ int amdgpu_atombios_get_max_vddc(struct amdgpu_device *adev, u8 voltage_type,
                args.v3.ucVoltageMode = ATOM_GET_VOLTAGE_LEVEL;
                args.v3.usVoltageLevel = cpu_to_le16(voltage_id);
 
-               amdgpu_atom_execute_table(adev->mode_info.atom_context, index, (uint32_t *)&args,
-                       sizeof(args));
+               if (amdgpu_atom_execute_table(adev->mode_info.atom_context,
+                   index, (uint32_t *)&args, sizeof(args)))
+                       return -EINVAL;
 
                *voltage = le16_to_cpu(args.v3.usVoltageLevel);
                break;