[PATCH] fs: sys_poll with timeout -1 bug fix
authorFrode Isaksen <frode.isaksen@gmail.com>
Sun, 25 Jun 2006 12:49:09 +0000 (05:49 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sun, 25 Jun 2006 17:01:22 +0000 (10:01 -0700)
If you do a poll() call with timeout -1, the wait will be a big number
(depending on HZ) instead of infinite wait, since -1 is passed to the
msecs_to_jiffies function.

Signed-off-by: Frode Isaksen <frode.isaksen@gmail.com>
Acked-by: Nishanth Aravamudan <nacc@us.ibm.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/select.c

index 9c4f0f2604f1e3435679bd0d55499979321edf7c..33b72ba0f86f45790bd7661053266cd8336c9757 100644 (file)
@@ -746,9 +746,9 @@ out_fds:
 asmlinkage long sys_poll(struct pollfd __user *ufds, unsigned int nfds,
                        long timeout_msecs)
 {
-       s64 timeout_jiffies = 0;
+       s64 timeout_jiffies;
 
-       if (timeout_msecs) {
+       if (timeout_msecs > 0) {
 #if HZ > 1000
                /* We can only overflow if HZ > 1000 */
                if (timeout_msecs / 1000 > (s64)0x7fffffffffffffffULL / (s64)HZ)
@@ -756,6 +756,9 @@ asmlinkage long sys_poll(struct pollfd __user *ufds, unsigned int nfds,
                else
 #endif
                        timeout_jiffies = msecs_to_jiffies(timeout_msecs);
+       } else {
+               /* Infinite (< 0) or no (0) timeout */
+               timeout_jiffies = timeout_msecs;
        }
 
        return do_sys_poll(ufds, nfds, &timeout_jiffies);