xe_file_open() stores task->comm in xef->process_name with kstrdup(),
but this diagnostic string is optional and the file open continues if
the allocation fails.

The timeout and devcoredump paths initialize process_name to the safe
"no process" fallback, then overwrite it whenever q->vm->xef exists. If
the kstrdup() failed, the fallback is replaced with NULL and the NULL
pointer is passed to string handling in diagnostic paths.

Keep the fallback process name unless xef->process_name was actually
allocated. Still report the stored pid when the xe file is available.

Fixes: 8af13c3fc125 ("drm/xe: Store process name and pid in xe file")
Signed-off-by: Ruoyu Wang <[email protected]>
---
 drivers/gpu/drm/xe/xe_devcoredump.c | 3 ++-
 drivers/gpu/drm/xe/xe_guc_submit.c  | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_devcoredump.c 
b/drivers/gpu/drm/xe/xe_devcoredump.c
index 11e60d6..fbe1fba 100644
--- a/drivers/gpu/drm/xe/xe_devcoredump.c
+++ b/drivers/gpu/drm/xe/xe_devcoredump.c
@@ -343,7 +343,8 @@ static void devcoredump_snapshot(struct xe_devcoredump 
*coredump,
        ss->boot_time = ktime_get_boottime();
 
        if (q->vm && q->vm->xef) {
-               process_name = q->vm->xef->process_name;
+               if (q->vm->xef->process_name)
+                       process_name = q->vm->xef->process_name;
                ss->pid = q->vm->xef->pid;
        }
 
diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c 
b/drivers/gpu/drm/xe/xe_guc_submit.c
index 2ac87ff..0892400 100644
--- a/drivers/gpu/drm/xe/xe_guc_submit.c
+++ b/drivers/gpu/drm/xe/xe_guc_submit.c
@@ -1189,7 +1189,8 @@ trigger_reset:
        }
 
        if (q->vm && q->vm->xef) {
-               process_name = q->vm->xef->process_name;
+               if (q->vm->xef->process_name)
+                       process_name = q->vm->xef->process_name;
                pid = q->vm->xef->pid;
        }
 
-- 
2.51.0

Reply via email to