lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Wed, 7 Jan 2015 09:38:34 +0200
From:	Asaf Vertz <asaf.vertz@...demg.com>
To:	josh.h.morris@...ibm.com
Cc:	pjk1939@...ux.vnet.ibm.com, linux-kernel@...r.kernel.org
Subject: [PATCH] rsxx: fix time comparison

To be future-proof and for better readability the time comparisons are
modified to use time_before() instead of plain, error-prone math.

Signed-off-by: Asaf Vertz <asaf.vertz@...demg.com>
---
 drivers/block/rsxx/core.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c
index d8b2488..ea527e8 100644
--- a/drivers/block/rsxx/core.c
+++ b/drivers/block/rsxx/core.c
@@ -25,6 +25,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/jiffies.h>
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/reboot.h>
@@ -513,8 +514,8 @@ static void card_event_handler(struct work_struct *work)
 static int card_shutdown(struct rsxx_cardinfo *card)
 {
 	unsigned int state;
-	signed long start;
-	const int timeout = msecs_to_jiffies(120000);
+	unsigned long start;
+	const unsigned long timeout = msecs_to_jiffies(120000);
 	int st;
 
 	/* We can't issue a shutdown if the card is in a transition state */
@@ -524,7 +525,7 @@ static int card_shutdown(struct rsxx_cardinfo *card)
 		if (st)
 			return st;
 	} while (state == CARD_STATE_STARTING &&
-		 (jiffies - start < timeout));
+		 time_before(jiffies, start + timeout));
 
 	if (state == CARD_STATE_STARTING)
 		return -ETIMEDOUT;
@@ -543,7 +544,7 @@ static int card_shutdown(struct rsxx_cardinfo *card)
 		if (st)
 			return st;
 	} while (state != CARD_STATE_SHUTDOWN &&
-		 (jiffies - start < timeout));
+		 time_before(jiffies, start + timeout));
 
 	if (state != CARD_STATE_SHUTDOWN)
 		return -ETIMEDOUT;
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ