Commit 547033b5 authored by Lin.Cao's avatar Lin.Cao Committed by Alex Deucher

drm/amdkfd: Check debug trap enable before write dbg_ev_file

In interrupt context, write dbg_ev_file will be run by work queue. It
will cause write dbg_ev_file execution after debug_trap_disable, which
will cause NULL pointer access.
v2: cancel work "debug_event_workarea" before set dbg_ev_file as NULL.
Signed-off-by: default avatarLin.Cao <lincao12@amd.com>
Reviewed-by: default avatarJonathan Kim <jonathan.kim@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent be168493
...@@ -104,7 +104,8 @@ void debug_event_write_work_handler(struct work_struct *work) ...@@ -104,7 +104,8 @@ void debug_event_write_work_handler(struct work_struct *work)
struct kfd_process, struct kfd_process,
debug_event_workarea); debug_event_workarea);
kernel_write(process->dbg_ev_file, &write_data, 1, &pos); if (process->debug_trap_enabled && process->dbg_ev_file)
kernel_write(process->dbg_ev_file, &write_data, 1, &pos);
} }
/* update process/device/queue exception status, write to descriptor /* update process/device/queue exception status, write to descriptor
...@@ -656,6 +657,7 @@ int kfd_dbg_trap_disable(struct kfd_process *target) ...@@ -656,6 +657,7 @@ int kfd_dbg_trap_disable(struct kfd_process *target)
else if (target->runtime_info.runtime_state != DEBUG_RUNTIME_STATE_DISABLED) else if (target->runtime_info.runtime_state != DEBUG_RUNTIME_STATE_DISABLED)
target->runtime_info.runtime_state = DEBUG_RUNTIME_STATE_ENABLED; target->runtime_info.runtime_state = DEBUG_RUNTIME_STATE_ENABLED;
cancel_work_sync(&target->debug_event_workarea);
fput(target->dbg_ev_file); fput(target->dbg_ev_file);
target->dbg_ev_file = NULL; target->dbg_ev_file = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment