Re: [PATCH v2 1/5] ftrace: Fix accounting of adding subops to a manager ops

From: Steven Rostedt
Date: Thu Feb 20 2025 - 15:06:07 EST


On Thu, 20 Feb 2025 15:58:58 +0900
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx> wrote:

> On Wed, 19 Feb 2025 17:04:37 -0500
> Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> > @@ -3292,16 +3299,18 @@ static int intersect_hash(struct ftrace_hash **hash, struct ftrace_hash *new_has
> > /* Return a new hash that has a union of all @ops->filter_hash entries */
> > static struct ftrace_hash *append_hashes(struct ftrace_ops *ops)
> > {
> > - struct ftrace_hash *new_hash;
> > + struct ftrace_hash *new_hash = NULL;
>
> Isn't this "= EMPTY_HASH"?
>

No it has to be NULL. As the change log stated:

Fix this by initializing the new hash to NULL and if the hash is NULL do
not treat it as an empty hash but instead allocate by copying the content
of the first sub ops. Then on subsequent iterations, the new hash will not
be NULL, but the content of the previous subops. If that first subops
attached to all functions, then new hash may assume that the manager ops
also needs to attach to all functions.


Hmm, but we should return EMPTY_HASH if new_hash is still NULL after the
update. Otherwise the caller may confuse this as a failed allocation.

I'll send a v3.

Thanks,

-- Steve