On Mon, 24 Sep 2012 12:59:41 -0300, Arnaldo Carvalho de Melo wrote: > From: Arnaldo Carvalho de Melo <a...@redhat.com> > > The pevent_parse_event() routine will parse a events/sys/tp/format file > and add an event_format instance to the pevent struct. > > This patch introduces a pevent_parse_format() routine with just the bits > needed to parse the event/sys/tp/format file and just return the > event_format instance, useful for when all we want is to parse the > format file, without requiring the pevent struct. [snip] > +enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf, > + unsigned long size, const char *sys) > +{ > + struct event_format *event = NULL; > + int ret = __pevent_parse_format(&event, pevent, buf, size, sys); > + > + if (event == NULL) > + return ret; > + > + /* Add pevent to event so that it can be referenced */ > + event->pevent = pevent; > + > + if (add_event(pevent, event)) > + goto event_add_failed;
It seems we should set the 'ret' to a proper pevent_errno - PEVENT_ERRNO__MEM_ALLOC_FAILED. > + > +#define PRINT_ARGS 0 > + if (PRINT_ARGS && event->print_fmt.args) > + print_args(event->print_fmt.args); > + > + return 0; > + > +event_add_failed: > + free(event->system); > + free(event->name); > + free(event); At this point, the 'event' also has fields and format information and they all need to be freed. Looks like calling pevent_free_format() would be the right thing IMHO. Thanks, Namhyung > return ret; > } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/