[PATCH] riscv: stacktrace: Fix NULL task pointer in^J ftrace_graph_ret_addr()

Paul Walmsley pjw at kernel.org
Mon Nov 30 18:09:42 PST 2026


On Wed, 8 Jul 2026, zhang.anmeng at zte.com.cn wrote:

> When dump_backtrace() is called with a NULL task argument, and the
> call stack contains functions that are being traced,
> walk_stackframe() eventually calls ftrace_graph_ret_addr() with the
> NULL task pointer, which results in a NULL pointer dereference when
> accessing task->curr_ret_stack.
> 
> Fix this by assigning the task pointer to the current task in
> walk_stackframe() when it is NULL, keeping the behavior consistent
> with other architectures.
> 
> Fixes: ecbf894165a2 ("riscv: Fix ftrace_graph_ret_addr() to use the correct task pointer")
> Reviewed-by: Shengming Hu <hu.shengming at zte.com.cn>
> Reviewed-by: Rui Gao <gao.rui at zte.com.cn>
> Reviewed-by: Luo Haiyang <luo.haiyang at zte.com.cn>
> Reviewed-by: Run Zhang <zhang.run at zte.com.cn>
> Signed-off-by: Anmeng Zhang <zhang.anmeng at zte.com.cn>

Thanks, queued for v7.4-rc with a cc to stable.


- Paul



More information about the linux-riscv mailing list