[PATCH] drm/amdgpu: return error from gpu_recover_get() on runtime pm failure

From: Haotian Zhang

Date: Thu Oct 08 2026 - 14:45:39 EST


gpu_recover_get() calls pm_runtime_get_sync() and, when it fails, puts the
runtime pm reference but returns 0 instead of the negative error code. It
also never writes *val in that path, and since the debugfs file is backed
by DEFINE_DEBUGFS_ATTRIBUTE/simple_attr_read(), a 0 return makes libfs
format an uninitialized on-stack u64 and expose the kernel stack contents
to userspace, while the error itself is silently discarded.

Return r so the failure is propagated and the caller skips formatting the
uninitialized value.

Fixes: a9ffe2a98338 ("drm/amdgpu/debugfs: properly handle runtime pm")
Assisted-by: DeepSeek-V4.1-Flash
Signed-off-by: Haotian Zhang <vulab@xxxxxxxxxxx>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
index 3043ad041bb4..4c373167d86d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
@@ -988,7 +988,7 @@ static int gpu_recover_get(void *data, u64 *val)
r = pm_runtime_get_sync(dev->dev);
if (r < 0) {
pm_runtime_put_autosuspend(dev->dev);
- return 0;
+ return r;
}

if (amdgpu_reset_domain_schedule(adev->reset_domain, &adev->reset_work))
--
2.25.1