Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 04a3446c authored by Frode Isaksen's avatar Frode Isaksen Committed by Linus Torvalds
Browse files

[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: default avatarFrode Isaksen <frode.isaksen@gmail.com>
Acked-by: default avatarNishanth Aravamudan <nacc@us.ibm.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 8bdd1d12
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -746,9 +746,9 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds, s64 *timeout)
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);