LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: akpm@linux-foundation.org
Cc: shawn.bohrer@gmail.com, davidel@xmailserver.org,
	linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
	mm-commits@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [patch] epoll-fix-compiler-warning-and-optimize-the-non-blocking-path-fix
Date: Wed, 26 Jan 2011 11:20:20 +0100	[thread overview]
Message-ID: <20110126102020.GA2244@cmpxchg.org> (raw)
In-Reply-To: <201101260021.p0Q0LxsS016458@imap1.linux-foundation.org>

The non-blocking ep_poll path optimization introduced skipping over
the return value setup.

Initialize it properly, my userspace gets upset by epoll_wait()
returning random things.

In addition, remove the reinitialization at the fetch_events label,
the return value is garuanteed to be zero when execution reaches
there.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Shawn Bohrer <shawn.bohrer@gmail.com>
Cc: Davide Libenzi <davidel@xmailserver.org>
---
 fs/eventpoll.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index f7cb6cb..afe4238 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -1147,7 +1147,7 @@ static int ep_send_events(struct eventpoll *ep,
 static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
 		   int maxevents, long timeout)
 {
-	int res, eavail, timed_out = 0;
+	int res = 0, eavail, timed_out = 0;
 	unsigned long flags;
 	long slack = 0;
 	wait_queue_t wait;
@@ -1173,7 +1173,6 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
 fetch_events:
 	spin_lock_irqsave(&ep->lock, flags);
 
-	res = 0;
 	if (!ep_events_available(ep)) {
 		/*
 		 * We don't have any available event to return to the caller.
-- 
1.7.3.5

  reply	other threads:[~2011-01-26 10:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-25 23:48 mmotm 2011-01-25-15-47 uploaded akpm
2011-01-26 10:20 ` Johannes Weiner [this message]
2011-01-26 15:05   ` [patch] epoll-fix-compiler-warning-and-optimize-the-non-blocking-path-fix Davide Libenzi
2011-01-26 19:16 ` [PATCH -mmotm] backlight: apple_bl depends on ACPI Randy Dunlap
2011-01-31 22:31   ` Matthew Garrett
2011-02-03  7:39 ` epoll broken [was: mmotm 2011-01-25-15-47 uploaded] Jiri Slaby
2011-02-03  7:53   ` Eric Dumazet
2011-02-03  9:03     ` Jiri Slaby

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110126102020.GA2244@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=akpm@linux-foundation.org \
    --cc=davidel@xmailserver.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mm-commits@vger.kernel.org \
    --cc=shawn.bohrer@gmail.com \
    --subject='Re: [patch] epoll-fix-compiler-warning-and-optimize-the-non-blocking-path-fix' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).