Skip to contentSkip to conversation

staging: fieldbus: anybus-s: fix wait_for_completion_timeout return handling

PATCH New Sven Van Asbroeck 1 participant 1 message May 1, 2019 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: fieldbus: anybus-s: fix wait_for_completion_timeout return handling

From: Nicholas Mc Guire <[email protected]>

wait_for_completion_timeout() returns unsigned long (0 on timeout or remaining jiffies) not int. Assigning this return value to int may theoretically overflow (though not in this case where TIMEOUT is only HZ*2).

Fix this inconsistency by wrapping the wait_for_completion_timeout into the if().

---
 drivers/staging/fieldbus/anybuss/host.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/fieldbus/anybuss/host.c +2 -3
index e34d4249f5a7..a64fe03b61fa 100644
@@ -1325,11 +1325,10 @@ anybuss_host_common_probe(struct device *dev,
 	 *   interrupt came in: ready to go !
 	 */
 	reset_deassert(cd);
-	ret = wait_for_completion_timeout(&cd->card_boot, TIMEOUT);
-	if (ret == 0)
+	if (!wait_for_completion_timeout(&cd->card_boot, TIMEOUT)) {
 		ret = -ETIMEDOUT;
-	if (ret < 0)
 		goto err_reset;
+	}
 	/*
 	 * according to the anybus docs, we're allowed to read these
 	 * without handshaking / reserving the area
Signature · 1 line
2.17.1