[PATCH] drm/amdgpu: Fix runtime PM leak in amdgpu_securedisplay_debugfs_write()

Wentao Liang posted 1 patch 1 week, 1 day ago
drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] drm/amdgpu: Fix runtime PM leak in amdgpu_securedisplay_debugfs_write()
Posted by Wentao Liang 1 week, 1 day ago
amdgpu_securedisplay_debugfs_write() resumes the device with
pm_runtime_get_sync() before parsing the debugfs input.  In the
SECUREDISPLAY send ROI CRC case, an invalid user input, i.e. a missing
or out of range phy_id, makes the function return -EINVAL without
calling pm_runtime_put_autosuspend(), leaking the runtime PM reference
and keeping the GPU awake.

Drop the runtime PM reference on the invalid input error path before
returning.

Fixes: 7e39d7ec3588 ("drm/amdgpu: Fix the uninitialized variable warning")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c
index 3739be1b71e0..fdb05f5857d3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c
@@ -137,6 +137,7 @@ static ssize_t amdgpu_securedisplay_debugfs_write(struct file *f, const char __u
 	case 2:
 		if (size < 3 || phy_id >= TA_SECUREDISPLAY_MAX_PHY) {
 			dev_err(adev->dev, "Invalid input: %s\n", str);
+			pm_runtime_put_autosuspend(dev->dev);
 			return -EINVAL;
 		}
 		mutex_lock(&psp->securedisplay_context.mutex);
-- 
2.34.1