On Thu, Jul 23, 2015 at 09:42:40AM +0000, Kaixu Xia wrote: > +static struct perf_event *convert_map_with_perf_event(void *value) > +{ > + struct perf_event *event; > + u32 fd; > + > + fd = *(u32 *)value; > + > + event = perf_event_get(fd); > + if (IS_ERR(event)) > + return NULL; > + > + /* limit the event type to PERF_TYPE_RAW > + * and PERF_TYPE_HARDWARE. > + */ > + if (event->attr.type != PERF_TYPE_RAW && > + event->attr.type != PERF_TYPE_HARDWARE) > + return NULL;
Aside from the ref-leak already mentioned; please introduce something like: const struct perf_event_attr *perf_event_attrs(struct perf_event *event); To avoid having to poke inside of the event outside of perf code. > + > + return event; > +} -- 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/