static char *synthesize_perf_probe_point(struct perf_probe_point *pp);
 static int convert_name_to_addr(struct perf_probe_event *pev,
                                const char *exec);
+static void clear_probe_trace_event(struct probe_trace_event *tev);
 static struct machine machine;
 
 /* Initialize symbol maps and path of vmlinux/modules */
        return ret;
 }
 
+static void clear_probe_trace_events(struct probe_trace_event *tevs, int ntevs)
+{
+       int i;
+
+       for (i = 0; i < ntevs; i++)
+               clear_probe_trace_event(tevs + i);
+}
+
 /* Try to find perf_probe_event with debuginfo */
 static int try_to_find_probe_trace_events(struct perf_probe_event *pev,
                                          struct probe_trace_event **tevs,
                                ret = add_module_to_probe_trace_events(*tevs,
                                                 ntevs, target);
                }
+               if (ret < 0) {
+                       clear_probe_trace_events(*tevs, ntevs);
+                       zfree(tevs);
+               }
                return ret < 0 ? ret : ntevs;
        }