diff options
author | Jean-Philippe Brucker <jean-philippe.brucker@arm.com> | 2018-04-04 18:53:52 +0100 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2018-04-06 11:28:12 +0100 |
commit | 5e9dd8524f7f7960e80125787e16f3ec8f258ddf (patch) | |
tree | c840949c119c8ec3a6251b9fa959ce706cfad78c | |
parent | bbea6c7ad7f6f2dbcebfe21d301f9b1cb9687538 (diff) | |
download | kvmtool-5e9dd8524f7f7960e80125787e16f3ec8f258ddf.tar.gz |
ioeventfd: Always add a new event to the list
With vhost, the USER_POLL flags isn't passed to ioeventfd__add_event,
the function returns early and doesn't add the new event to the
used_ioevents list. As a result ioeventfd__del_event doesn't remove the
KVM event or free the structure. Always add the event to the list.
Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r-- | ioeventfd.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/ioeventfd.c b/ioeventfd.c index bce68619..186ac703 100644 --- a/ioeventfd.c +++ b/ioeventfd.c @@ -154,18 +154,17 @@ int ioeventfd__add_event(struct ioevent *ioevent, int flags) goto cleanup; } - if (!(flags & IOEVENTFD_FLAG_USER_POLL)) - return 0; - - epoll_event = (struct epoll_event) { - .events = EPOLLIN, - .data.ptr = new_ioevent, - }; - - r = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, event, &epoll_event); - if (r) { - r = -errno; - goto cleanup; + if (flags & IOEVENTFD_FLAG_USER_POLL) { + epoll_event = (struct epoll_event) { + .events = EPOLLIN, + .data.ptr = new_ioevent, + }; + + r = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, event, &epoll_event); + if (r) { + r = -errno; + goto cleanup; + } } list_add_tail(&new_ioevent->list, &used_ioevents); |