aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrode Isaksen <frode.isaksen@gmail.com>2006-06-25 08:49:09 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-25 13:01:22 -0400
commit04a3446c90137a473837288b04b517b19dc67a0d (patch)
tree874f1681da03441b021f81446e72ace451b0cb09
parent8bdd1d1250d55afe403ac4affa6ccc5f9e60468f (diff)
[PATCH] fs: sys_poll with timeout -1 bug fix
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>
-rw-r--r--fs/select.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/select.c b/fs/select.c
index 9c4f0f2604f1..33b72ba0f86f 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -746,9 +746,9 @@ out_fds:
746asmlinkage long sys_poll(struct pollfd __user *ufds, unsigned int nfds, 746asmlinkage long sys_poll(struct pollfd __user *ufds, unsigned int nfds,
747 long timeout_msecs) 747 long timeout_msecs)
748{ 748{
749 s64 timeout_jiffies = 0; 749 s64 timeout_jiffies;
750 750
751 if (timeout_msecs) { 751 if (timeout_msecs > 0) {
752#if HZ > 1000 752#if HZ > 1000
753 /* We can only overflow if HZ > 1000 */ 753 /* We can only overflow if HZ > 1000 */
754 if (timeout_msecs / 1000 > (s64)0x7fffffffffffffffULL / (s64)HZ) 754 if (timeout_msecs / 1000 > (s64)0x7fffffffffffffffULL / (s64)HZ)
@@ -756,6 +756,9 @@ asmlinkage long sys_poll(struct pollfd __user *ufds, unsigned int nfds,
756 else 756 else
757#endif 757#endif
758 timeout_jiffies = msecs_to_jiffies(timeout_msecs); 758 timeout_jiffies = msecs_to_jiffies(timeout_msecs);
759 } else {
760 /* Infinite (< 0) or no (0) timeout */
761 timeout_jiffies = timeout_msecs;
759 } 762 }
760 763
761 return do_sys_poll(ufds, nfds, &timeout_jiffies); 764 return do_sys_poll(ufds, nfds, &timeout_jiffies);