[bug report] tracing: Add a probe that attaches to trace events

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Tzvetomir Stoyanov (VMware),

This is a semi-automatic email about new static checker warnings.

The patch 7491e2c44278: "tracing: Add a probe that attaches to trace
events" from Aug 19, 2021, leads to the following Smatch complaint:

    kernel/trace/trace_eprobe.c:674 enable_trace_eprobe()
    warn: variable dereferenced before check 'file' (see line 664)

kernel/trace/trace_eprobe.c
   638  static int enable_trace_eprobe(struct trace_event_call *call,
   639                                 struct trace_event_file *file)
   640  {
   641          struct trace_probe *pos, *tp;
   642          struct trace_eprobe *ep;
   643          bool enabled;
   644          int ret = 0;
   645  
   646          tp = trace_probe_primary_from_call(call);
   647          if (WARN_ON_ONCE(!tp))
   648                  return -ENODEV;
   649          enabled = trace_probe_is_enabled(tp);
   650  
   651          /* This also changes "enabled" state */
   652          if (file) {
   653                  ret = trace_probe_add_file(tp, file);
   654                  if (ret)
   655                          return ret;
   656          } else
   657                  trace_probe_set_flag(tp, TP_FLAG_PROFILE);
   658  
   659          if (enabled)
   660                  return 0;
   661  
   662          list_for_each_entry(pos, trace_probe_probe_list(tp), list) {
   663			ep = container_of(pos, struct trace_eprobe, tp);
   664			ret = enable_eprobe(ep, file);
                                                ^^^^
"file" is dereferenced here.

   665			if (ret)
   666				break;
   667			enabled = true;
   668		}
   669	
   670		if (ret) {
   671			/* Failed to enable one of them. Roll back all */
   672			if (enabled)
   673				disable_eprobe(ep, file->tr);
   674			if (file)
                            ^^^^
This check is too late.

   675				trace_probe_remove_file(tp, file);
   676			else

regards,
dan carpenter



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux