Re: [PATCH 2/2] tracing: fprobe: Fix to remove recorded module addresses from filter

menglong.dong
2025-09-24T01:55:37Z

> Even if there is a memory allocation failure in fprobe_addr_list_add(),
> there is a partial list of module addresses. So remove the recorded
> addresses from filter if exists.
> This also removes the redundant ret local variable.

I think this is what you do in the previous patch?

The rest looks good to me.

Reviewed-by: Menglong Dong <menglong8.dong@gmail.com>

(I think I should use Reviewed-by here, rather than Acked-by,
right?)

Thanks!
Menglong Dong

>
> Fixes: a3dc2983ca7b ("tracing: fprobe: Cleanup fprobe hash when module unloading")
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> ---
> kernel/trace/fprobe.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c
> index 12ec194fdfed..95e43814b85b 100644
> --- a/kernel/trace/fprobe.c
> +++ b/kernel/trace/fprobe.c
> @@ -434,8 +434,9 @@ static int fprobe_addr_list_add(struct fprobe_addr_list *alist, unsigned long ad
> {
> unsigned long *addrs;
>
> - if (alist->index >= alist->size)
> - return -ENOMEM;
> + /* Previously we failed to expand the list. */
> + if (alist->index == alist->size)
> + return -ENOSPC;
>
> alist->addrs[alist->index++] = addr;
> if (alist->index < alist->size)
> @@ -497,7 +498,7 @@ static int fprobe_module_callback(struct notifier_block *nb,
> } while (node == ERR_PTR(-EAGAIN));
> rhashtable_walk_exit(&iter);
>
> - if (alist.index < alist.size && alist.index > 0)
> + if (alist.index > 0)
> ftrace_set_filter_ips(&fprobe_graph_ops.ops,
> alist.addrs, alist.index, 1, 0);
> mutex_unlock(&fprobe_mutex);
>
>
>