drm/amdgpu: Fix the uninitialized variable warning
authorMa Jun <Jun.Ma2@amd.com>
Wed, 24 Apr 2024 07:44:56 +0000 (15:44 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 8 May 2024 19:17:04 +0000 (15:17 -0400)
Check the user input and phy_id value range to fix
"Using uninitialized value phy_id"

Signed-off-by: Ma Jun <Jun.Ma2@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c

index 8ed0e07..41ebe69 100644 (file)
@@ -135,6 +135,10 @@ static ssize_t amdgpu_securedisplay_debugfs_write(struct file *f, const char __u
                mutex_unlock(&psp->securedisplay_context.mutex);
                break;
        case 2:
+               if (size < 3 || phy_id >= TA_SECUREDISPLAY_MAX_PHY) {
+                       dev_err(adev->dev, "Invalid input: %s\n", str);
+                       return -EINVAL;
+               }
                mutex_lock(&psp->securedisplay_context.mutex);
                psp_prep_securedisplay_cmd_buf(psp, &securedisplay_cmd,
                        TA_SECUREDISPLAY_COMMAND__SEND_ROI_CRC);