On Sat, Apr 18, 2026 at 06:10:52AM +0000, [email protected] wrote:
> > diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
> > --- a/include/linux/ftrace.h
> > +++ b/include/linux/ftrace.h
> > @@ -416,6 +416,7 @@ void free_ftrace_hash(struct ftrace_hash *hash);
> >  struct ftrace_func_entry *add_ftrace_hash_entry_direct(struct ftrace_hash 
> > *hash,
> >                                                    unsigned long ip, 
> > unsigned long direct);
> >  unsigned long ftrace_hash_count(struct ftrace_hash *hash);
> > +void ftrace_hash_remove(struct ftrace_hash *hash);
> >
> >  /* The hash used to know what functions callbacks trace */
> >  struct ftrace_ops_hash {
> > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> > --- a/kernel/trace/ftrace.c
> > +++ b/kernel/trace/ftrace.c
> > @@ -1249,6 +1249,25 @@ remove_hash_entry(struct ftrace_hash *hash,
> >     hash->count--;
> >  }
> >
> > +void ftrace_hash_remove(struct ftrace_hash *hash)
> > +{
> > +   struct hlist_head *hhd;
> > +   struct hlist_node *tn;
> > +   struct ftrace_func_entry *entry;
> > +   int size = 1 << hash->size_bits;
>                           ^^^^^^^^^^^^^^^^
> 
> Can this dereference a NULL pointer? The code computes the size using
> hash->size_bits before checking if hash is NULL:
> 
>     int size = 1 << hash->size_bits;
>     ...
>     if (!hash || !hash->count)
>         return;

yep, we should deref after the check, will fix

jirka

Reply via email to