Skip to contentSkip to conversation

drm/amdgpu: Fix the uninitialized variable warning

PATCH In review Ma Jun 3 participants 3 messages Apr 26, 2024 – Apr 29, 2024

Subsystems (2)
lore
Share & tools
lore

Ma Jun

author
#0 lore raw

PATCH v3 1/1 drm/amdgpu: Fix the uninitialized variable warning

Check the user input and phy_id value range to fix "Using uninitialized value phy_id"

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c +4 -0
index 8ed0e073656f..41ebe690eeff 100644
@@ -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);
Signature · 1 line
2.34.1
#1 lore raw

ping ...

Quoted 23 lines · Ma Jun

Check the user input and phy_id value range to fix "Using uninitialized value phy_id"

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c +4 -0
index 8ed0e073656f..41ebe690eeff 100644
@@ -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);
Reviewed-by on v3 1/1
#2 lore raw
In reply to Ma Jun
Quoted 5 lines · Ma Jun

Check the user input and phy_id value range to fix "Using uninitialized value phy_id"

Quoted 22 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c +4 -1
index 8ed0e073656f..41ebe690eeff 100644
@@ -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);
--

2.34.1