]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
drm/amdkfd: Unwind debug trap enable on copy_to_user failure
authorYongqiang Sun <Yongqiang.Sun@amd.com>
Tue, 2 Jun 2026 13:59:44 +0000 (09:59 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 4 Jun 2026 20:00:11 +0000 (16:00 -0400)
commita50676d5a72a26829d4885ff7d62df8d82f462b1
tree79f56e9d124429c166117d65a8a442ceffb11e4c
parent9c6ffdb41fa5dcf47a262c656e9f443d0d26049c
drm/amdkfd: Unwind debug trap enable on copy_to_user failure

If kfd_dbg_trap_enable() fails while copying runtime_info to userspace,
it had already activated the trap, set debug_trap_enabled, taken an extra
process reference, and opened the debug event file. Return -EFAULT without
unwinding that state, leaving inconsistent trap state and a refcount
imbalance that could break later DISABLE/ENABLE.

On copy_to_user failure, deactivate the trap and undo the rest of the
enable setup before returning.

Signed-off-by: Yongqiang Sun <Yongqiang.Sun@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 01112e241e37f9ac98b6f418d93ce2e0b87b7ee0)
drivers/gpu/drm/amd/amdkfd/kfd_debug.c