All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: fieldbus: anybus-s: fix wait_for_completion_timeout return handling
@ 2019-05-01 14:35 Sven Van Asbroeck
  2019-05-01 14:37 ` Sven Van Asbroeck
  0 siblings, 1 reply; 3+ messages in thread
From: Sven Van Asbroeck @ 2019-05-01 14:35 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, Nicholas Mc Guire

From: Nicholas Mc Guire <hofrat@osadl.org>

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().

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Reviewed-by: Sven Van Asbroeck <TheSven73@googlemail.com>
---
 drivers/staging/fieldbus/anybuss/host.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/fieldbus/anybuss/host.c b/drivers/staging/fieldbus/anybuss/host.c
index e34d4249f5a7..a64fe03b61fa 100644
--- a/drivers/staging/fieldbus/anybuss/host.c
+++ b/drivers/staging/fieldbus/anybuss/host.c
@@ -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
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: fieldbus: anybus-s: fix wait_for_completion_timeout return handling
  2019-05-01 14:35 [PATCH] staging: fieldbus: anybus-s: fix wait_for_completion_timeout return handling Sven Van Asbroeck
@ 2019-05-01 14:37 ` Sven Van Asbroeck
  0 siblings, 0 replies; 3+ messages in thread
From: Sven Van Asbroeck @ 2019-05-01 14:37 UTC (permalink / raw)
  To: Greg KH; +Cc: Linux Kernel Mailing List

On Wed, May 1, 2019 at 10:35 AM Sven Van Asbroeck <thesven73@gmail.com> wrote:
>
> Reviewed-by: Sven Van Asbroeck <TheSven73@googlemail.com>

Ouch, this isn't right. I'll re-send the patch. Sorry.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] staging: fieldbus: anybus-s: fix wait_for_completion_timeout return handling
@ 2019-05-01 14:38 Sven Van Asbroeck
  0 siblings, 0 replies; 3+ messages in thread
From: Sven Van Asbroeck @ 2019-05-01 14:38 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, Nicholas Mc Guire

From: Nicholas Mc Guire <hofrat@osadl.org>

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().

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Reviewed-by: Sven Van Asbroeck <TheSven73@gmail.com>
---
 drivers/staging/fieldbus/anybuss/host.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/fieldbus/anybuss/host.c b/drivers/staging/fieldbus/anybuss/host.c
index e34d4249f5a7..a64fe03b61fa 100644
--- a/drivers/staging/fieldbus/anybuss/host.c
+++ b/drivers/staging/fieldbus/anybuss/host.c
@@ -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
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-01 14:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-01 14:35 [PATCH] staging: fieldbus: anybus-s: fix wait_for_completion_timeout return handling Sven Van Asbroeck
2019-05-01 14:37 ` Sven Van Asbroeck
2019-05-01 14:38 Sven Van Asbroeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.