diff --git a/fs/eventpoll.c b/fs/eventpoll.c index a569e98d4a99..4973a5a5a3e1 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -1685,7 +1685,7 @@ static int reverse_path_check(struct ep_ctl_ctx *ctx) { struct epitems_head *p; - for (p = ctx->tfile_check_list; p; p = p->next) { + for (p = ctx->tfile_check_list; p != EP_UNACTIVE_PTR; p = p->next) { int error; path_count_init(ctx); rcu_read_lock(); @@ -2438,7 +2438,7 @@ static int ep_loop_check(struct ep_ctl_ctx *ctx, struct eventpoll *ep, static void clear_tfile_check_list(struct ep_ctl_ctx *ctx) { rcu_read_lock(); - while (ctx->tfile_check_list) { + while (ctx->tfile_check_list != EP_UNACTIVE_PTR) { struct epitems_head *head = ctx->tfile_check_list; ctx->tfile_check_list = head->next; unlist_file(head); @@ -2601,7 +2601,9 @@ int do_epoll_ctl_file(struct file *f, int op, struct epoll_key *tf, int full_check; struct eventpoll *ep; struct epitem *epi; - struct ep_ctl_ctx ctx = { }; + struct ep_ctl_ctx ctx = { + .tfile_check_list = EP_UNACTIVE_PTR, + }; /* The target file descriptor must support poll */ if (!file_can_poll(tf->file))