diff --git a/cr-check.c b/cr-check.c index fe7d03c99..7647cacb9 100644 --- a/cr-check.c +++ b/cr-check.c @@ -299,7 +299,8 @@ static int check_fdinfo_signalfd(void) static int check_one_epoll(union fdinfo_entries *e, void *arg) { - *(int *)arg = e->epl.tfd; + *(int *)arg = e->epl.e.tfd; + free_event_poll_entry(e); return 0; } diff --git a/eventpoll.c b/eventpoll.c index 88b331f1a..da40e92cd 100644 --- a/eventpoll.c +++ b/eventpoll.c @@ -59,12 +59,16 @@ static void pr_info_eventpoll(char *action, EventpollFileEntry *e) static int dump_eventpoll_entry(union fdinfo_entries *e, void *arg) { - EventpollTfdEntry *efd = &e->epl; + EventpollTfdEntry *efd = &e->epl.e; + int ret; efd->id = *(u32 *)arg; pr_info_eventpoll_tfd("Dumping: ", efd); - return pb_write_one(fdset_fd(glob_fdset, CR_FD_EVENTPOLL_TFD), + ret = pb_write_one(fdset_fd(glob_fdset, CR_FD_EVENTPOLL_TFD), efd, PB_EVENTPOLL_TFD); + + free_event_poll_entry(e); + return ret; } static int dump_one_eventpoll(int lfd, u32 id, const struct fd_parms *p) diff --git a/include/proc_parse.h b/include/proc_parse.h index e583f2999..7fade0669 100644 --- a/include/proc_parse.h +++ b/include/proc_parse.h @@ -182,17 +182,23 @@ struct fanotify_mark_entry { }; }; +struct eventpoll_tfd_entry { + EventpollTfdEntry e; + struct list_head node; +}; + union fdinfo_entries { EventfdFileEntry efd; - EventpollTfdEntry epl; SignalfdEntry sfd; struct inotify_wd_entry ify; struct fanotify_mark_entry ffy; + struct eventpoll_tfd_entry epl; TimerfdEntry tfy; }; extern void free_inotify_wd_entry(union fdinfo_entries *e); extern void free_fanotify_mark_entry(union fdinfo_entries *e); +extern void free_event_poll_entry(union fdinfo_entries *e); struct fdinfo_common { off64_t pos; diff --git a/proc_parse.c b/proc_parse.c index 0a3e3c059..01ae43eca 100644 --- a/proc_parse.c +++ b/proc_parse.c @@ -1051,6 +1051,11 @@ void free_fanotify_mark_entry(union fdinfo_entries *e) xfree(e); } +void free_event_poll_entry(union fdinfo_entries *e) +{ + xfree(e); +} + static void parse_fhandle_encoded(char *tok, FhEntry *fh) { char *d = (char *)fh->handle; @@ -1195,15 +1200,24 @@ static int parse_fdinfo_pid_s(char *pid, int fd, int type, continue; } if (fdinfo_field(str, "tfd")) { - eventpoll_tfd_entry__init(&entry.epl); + union fdinfo_entries *e; if (type != FD_TYPES__EVENTPOLL) goto parse_err; + + e = xmalloc(sizeof(union fdinfo_entries)); + if (!e) + goto out; + + eventpoll_tfd_entry__init(&e->epl.e); + ret = sscanf(str, "tfd: %d events: %x data: %"PRIx64, - &entry.epl.tfd, &entry.epl.events, &entry.epl.data); - if (ret != 3) + &e->epl.e.tfd, &e->epl.e.events, &e->epl.e.data); + if (ret != 3) { + free_event_poll_entry(e); goto parse_err; - ret = cb(&entry, arg); + } + ret = cb(e, arg); if (ret) goto out;