On Tue, 7 Jan 2025 10:42:31 -0500
Steven Rostedt <rost...@goodmis.org> wrote:

> On Tue,  7 Jan 2025 20:50:35 +0900
> "Masami Hiramatsu (Google)" <mhira...@kernel.org> wrote:
> 
> > @@ -1898,7 +1899,8 @@ create_local_trace_kprobe(char *func, void *addr, 
> > unsigned long offs,
> >                       bool is_return)
> >  {
> >     enum probe_print_type ptype;
> > -   struct trace_kprobe *tk;
> > +   struct trace_kprobe *tk __free(free_trace_kprobe) = NULL;
> > +   struct trace_probe *tp;
> >     int ret;
> >     char *event;
> >  
> > @@ -1929,19 +1931,16 @@ create_local_trace_kprobe(char *func, void *addr, 
> > unsigned long offs,
> >  
> >     ptype = trace_kprobe_is_return(tk) ?
> >             PROBE_PRINT_RETURN : PROBE_PRINT_NORMAL;
> > -   if (traceprobe_set_print_fmt(&tk->tp, ptype) < 0) {
> > -           ret = -ENOMEM;
> > -           goto error;
> > -   }
> > +   if (traceprobe_set_print_fmt(&tk->tp, ptype) < 0)
> > +           return ERR_PTR(-ENOMEM);
> >  
> >     ret = __register_trace_kprobe(tk);
> >     if (ret < 0)
> > -           goto error;
> > +           return ERR_PTR(ret);
> >  
> > -   return trace_probe_event_call(&tk->tp);
> > -error:
> > -   free_trace_kprobe(tk);
> > -   return ERR_PTR(ret);
> 
> 
> > +   tp = &tk->tp;
> > +   tk = NULL;      /* 'tk' is registered successfully, so do not free. */
> 
> I wonder if we could change the above to just:
> 
>       tp = &(no_free_ptr(tk)->tp);

Ah, that's nice idea. Then I can remove 'tp' as;

        return trace_probe_event_call(&(no_free_ptr(tk)->tp));

Thanks!

> 
> ?
> 
> -- Steve
> 
> > +   return trace_probe_event_call(tp);
> >  }
> >  
> >  void destroy_local_trace_kprobe(struct trace_event_call *event_call)
> 


-- 
Masami Hiramatsu (Google) <mhira...@kernel.org>

Reply via email to